Rearrange the blog post layout in REST

7 views
Skip to first unread message

Eric Dorman

unread,
Dec 6, 2009, 10:37:36 PM12/6/09
to NextDB Users
Hey guys,

I would like to rearrange my blog post layout for my posts and have my
title first in bold and then my description in my below REST url.

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY

geoffrey hendrey

unread,
Dec 6, 2009, 10:50:46 PM12/6/09
to nextd...@googlegroups.com
Hi Eric,

with XSLT you can reformat the data to appear any way you want. XSLT can be a learning curve, like any other technique, but it's not that hard. What I recommend you do is to write a simple HTML template that shows, with some canned blog post, how you want your blog post to look. Post that HTML back to this list, and I will show you how to turn your HTML template into a simple XSLT that will populate itself from each row of the database. So reply with your vision for how you want the page to look. Something like:

<html>
<body>
<title>Eric's sports blog</title>
<div id='blogPost'>
  <h1>Texas Wins In Final Seconds</h1>
   <p>
     blah blah vlah sports stuff
   <p>
<div>
</body>
</html>


Then I will show you how to use XSLT to pull the content of <h1> and <p> out of the 'title' and 'body' columns of your database.

-geoff


--

You received this message because you are subscribed to the Google Groups "NextDB Users" group.
To post to this group, send email to nextd...@googlegroups.com.
To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.





--
http://nextdb.net - RESTful Relational Database
http://www.nextdb.net/wiki/en/REST

Eric Dorman

unread,
Dec 6, 2009, 11:28:07 PM12/6/09
to NextDB Users
Hey Geoff,

You did it exactly how I would like for it to display,but it will
automaticly format to the way I want to be layed out when I enter a
new post won't it?

How I want it to layout:

>
> <html>
> <body>
> <title>Eric's sports blog</title>
> <div id='blogPost'>
> <h1>Texas Wins In Final Seconds</h1>
> <p>
> blah blah vlah sports stuff
> <p>
> <div>
> </body>
> </html>

I can probably create a whole website type layout with XSLT & HTML
can't I with the REST api?

God Bless,
Eric
> > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
> > .

geoffrey hendrey

unread,
Dec 7, 2009, 12:32:02 AM12/7/09
to nextd...@googlegroups.com
Hi Eric,

I created an XSLT (attached for reference). You'll want to put it online somewhere else, perhaps in your own nextdb database table, or on a web server somewhere.

I put it in my nextdb "sports" database here, as a temporary place to keep it online:

http://www.nextdb.net/nextdb/rest/geoff/sports/config/row/1/blog.xslt

Then I just pass the URL-encoded URL to the xslt file to your own database URL, like this:

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY;xslt=http%3A%2F%2Fwww.nextdb.net%2Fnextdb%2Frest%2Fgeoff%2Fsports%2Fconfig%2Frow%2F1%2Fblog.xslt

Notice the error message that comes back? It's because you have an unclosed img tag. For the moment, the XSLT is very finicky about having perfectly formatted XHTML. I'm fixing that...you can read about what I am doing with JTidy here: http://notskateboarding.blogspot.com/2009/12/jtidy-and-handling-html-embedded-in.html

However, until I push out the JTidy software to "cleanup" scuzzy HTML, you will need to make your HTML have proper closing tags, etc. Once you do that, the URL above should return your blog posts the way you want them.

Cheers,
-geoff



To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


sportsblog.xslt

Eric Dorman

unread,
Dec 7, 2009, 2:21:48 AM12/7/09
to NextDB Users
Hey Geoff,

Thanks for all that information.

Can I make sort like a website layout in XSLT?

I am wanting to really make a layout that looks almost like a magazine
layout or a blog layout.

I am not sure I understand the unclosed img tag cause I thought it was
closed already.

Can you give me instructions on how to close the img tag cause I am
really confused about where to go.

God Bless,
Eric

On Dec 7, 12:32 am, geoffrey hendrey <geoff.hend...@gmail.com> wrote:
> Hi Eric,
>
> I created an XSLT (attached for reference). You'll want to put it online
> somewhere else, perhaps in your own nextdb database table, or on a web
> server somewhere.
>
> I put it in my nextdb "sports" database here, as a temporary place to keep
> it online:
>
> http://www.nextdb.net/nextdb/rest/geoff/sports/config/row/1/blog.xslt
>
> Then I just pass the URL-encoded URL to the xslt file to your own database
> URL, like this:
>
> http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY;xslt=http%3A%2...
>
> Notice the error message that comes back? It's because you have an unclosed
> img tag. For the moment, the XSLT is very finicky about having perfectly
> formatted XHTML. I'm fixing that...you can read about what I am doing with
> JTidy here:http://notskateboarding.blogspot.com/2009/12/jtidy-and-handling-html-...
> > <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nextdb-user?hl=en.
>
> > > --http://nextdb.net-RESTful Relational Databasehttp://
> >www.nextdb.net/wiki/en/REST
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "NextDB Users" group.
> > To post to this group, send email to nextd...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nextdb-user?hl=en.
>
> --http://nextdb.net- RESTful Relational Databasehttp://www.nextdb.net/wiki/en/REST
>
>  sportsblog.xslt
> 2KViewDownload

geoffrey hendrey

unread,
Dec 7, 2009, 11:26:44 AM12/7/09
to nextd...@googlegroups.com
In your blog you have an img tag:
<img  src="http://a323.yahoofs.com/ymg/ept_sports_ncaaf_experts__28/ept_sports_ncaaf_experts-69781189-1260076560.jpg?ymQINUCDXpJTM34Q">

you need to close the image tag by adding </img>
I think the error message was spot on: "The element type "img" must be terminated by the matching end-tag "</img>".

Basically HTML, as practiced by most people, is sloppy -- it isn't valid XML. The XSLT transformation requires that the input be valid XML. So cleanup the sloppy HTML by closing your tags, and using a validating XHTML editor. I'll get JTidy deployed on the server and then the cleanup will happen automatically.

-geoff



To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


Eric Dorman

unread,
Dec 7, 2009, 5:05:38 PM12/7/09
to NextDB Users
Hey Geoff,

I have now added the newspaper type theme to my blog enteries in REST.

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspaper-a

But now I have found that the most recent blog posts should be at the
top,but the most recent blog post is at the bottom as you can see in
the link below.

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspaper-a

Is their a way to rearrange my posts so that my most blog post
submitted is on top?

Thanks & God Bless,
Eric

On Dec 7, 11:26 am, geoffrey hendrey <geoff.hend...@gmail.com> wrote:
> In your blog you have an img tag:
>
> <img  src="http://a323.yahoofs.com/ymg/ept_sports_ncaaf_experts__28/ept_sports_n...
> <view-source:http://a323.yahoofs.com/ymg/ept_sports_ncaaf_experts__28/ept_sports_n...>">
> > > > <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
> > <nextdb-user%252Buns...@googlegroups.com<nextdb-user%25252Bun...@googlegroups.com>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/nextdb-user?hl=en.
>
> > > > > --http://nextdb.net-RESTfulRelational Databasehttp://
> > > >www.nextdb.net/wiki/en/REST
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "NextDB Users" group.
> > > > To post to this group, send email to nextd...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
> > <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nextdb-user?hl=en.
>
> > > --http://nextdb.net-RESTful Relational Databasehttp://
> >www.nextdb.net/wiki/en/REST
>

geoffrey hendrey

unread,
Dec 7, 2009, 5:08:34 PM12/7/09
to nextd...@googlegroups.com
use descending/created

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspaper-a/descending/created

-geoff

To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


geoffrey hendrey

unread,
Dec 7, 2009, 5:09:40 PM12/7/09
to nextd...@googlegroups.com
oh, by the way why don't you fix the img tags so you can use an XSLT for a nice layout?

geoffrey hendrey

unread,
Dec 7, 2009, 5:11:05 PM12/7/09
to nextd...@googlegroups.com
and one other thing: don't you want to show just the posts with public=1?

http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspaper-a/descending/created/public/1

Eric Dorman

unread,
Dec 7, 2009, 5:54:54 PM12/7/09
to NextDB Users
Hey Geoff,

You mean posts that I make public?

Then yes I want the public to =1

But I still would like to have my most recent post at the top.

In the Nextdb Admin Panel how would I go about adding a sidebar to my
REST Blog Entry Results?

-Eric

On Dec 7, 5:11 pm, geoffrey hendrey <geoff.hend...@gmail.com> wrote:
> and one other thing: don't you want to show just the posts with public=1?
>
> http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspape...
>
> On Mon, Dec 7, 2009 at 2:09 PM, geoffrey hendrey <geoff.hend...@gmail.com>wrote:
>
> > oh, by the way why don't you fix the img tags so you can use an XSLT for a
> > nice layout?
>
> > On Mon, Dec 7, 2009 at 2:08 PM, geoffrey hendrey <geoff.hend...@gmail.com>wrote:
>
> >> use descending/created
>
> >>http://nextdb.net/nextdb/rest/dorman/test43/BLOG_ENTRY/style/newspape...
>
> >> -geoff
> >>> > > > > <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
> >>> <nextdb-user%252Buns...@googlegroups.com<nextdb-user%25252Bun...@googlegroups.com>
>
> >>> > > <nextdb-user%252Buns...@googlegroups.com<nextdb-user%25252Bun...@googlegroups.com>
> >>> <nextdb-user%25252Bun...@googlegroups.com<nextdb-user%2525252Bu...@googlegroups.com>
>
> >>> > > > > > > .
> >>> > > > > > > For more options, visit this group at
> >>> > > > > > >http://groups.google.com/group/nextdb-user?hl=en.
>
> >>> > > > > > --http://nextdb.net-RESTfulRelationalDatabasehttp://
> >>> > > > >www.nextdb.net/wiki/en/REST
>
> >>> > > > > --
>
> >>> > > > > You received this message because you are subscribed to the
> >>> Google
> >>> > > Groups
> >>> > > > > "NextDB Users" group.
> >>> > > > > To post to this group, send email to
> >>> nextd...@googlegroups.com.
> >>> > > > > To unsubscribe from this group, send email to
> >>> > > > > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
> >>> <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
>
> >>> > > <nextdb-user%2Bunsu...@googlegroups.com<nextdb-user%252Buns...@googlegroups.com>
> >>> <nextdb-user%252Buns...@googlegroups.com<nextdb-user%25252Bun...@googlegroups.com>
>
> >>> > > > > .
> >>> > > > > For more options, visit this group at
> >>> > > > >http://groups.google.com/group/nextdb-user?hl=en.
>
> >>> > > > --http://nextdb.net-RESTfulRelational Databasehttp://
> >>> > >www.nextdb.net/wiki/en/REST
>
> >>> > > >  sportsblog.xslt
> >>> > > > 2KViewDownload
>
> >>> > > --
>
> >>> > > You received this message because you are subscribed to the Google
> >>> Groups
> >>> > > "NextDB Users" group.
> >>> > > To post to this group, send email to nextd...@googlegroups.com.
> >>> > > To unsubscribe from this group, send email to
> >>> > > nextdb-user...@googlegroups.com<nextdb-user%2Bunsu...@googlegroups.com>
>
> ...
>
> read more »

Geoffrey Hendrey

unread,
Dec 7, 2009, 6:51:52 PM12/7/09
to nextd...@googlegroups.com
Yeah. Your most recent *public* post at the top. That's why the URL
uses /descending/created/public/1

This means the ordering is descending on the 'created' column and the
column public must be equal to 1.

I'm not going to answer your question about how to create a sidebar
for your layout. Address that to a forum for web design. Hopefully you
understand that once you have your HTML mocked up with your sidebar,
that you would use xslt to make it dynamic. I'm not convince you've
understood me on the xslt front - mainly because I don't see that
you've used it.

-geoff
>> ...
>>
>> read more »
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "NextDB Users" group.
> To post to this group, send email to nextd...@googlegroups.com.
> To unsubscribe from this group, send email to nextdb-user...@googlegroups.com

Eric Dorman

unread,
Dec 7, 2009, 7:20:24 PM12/7/09
to NextDB Users
Hey Geoff,

No, I didn't mean you have to answer that web design question. All I
was asking was is it possible to add a sidebar in the html,but I now
remember you answered that back in the first few posts. Sorry I
sometimes forget. :)

Honestly, no I still don't understand because XSLT is very unfamiliar
to me and so that's why I am still having trouble with it. I am trying
to learn it though through online documentation of the language.

Sorry I just want to make sure I understand correctly. :)


On Dec 7, 6:51 pm, Geoffrey Hendrey <geoff.hend...@gmail.com> wrote:
> Yeah.  Your most recent *public* post at the top. That's why the URL  
> uses /descending/created/public/1
>
> This means the ordering is descending on the 'created' column and the  
> column public must be equal to 1.
>
> I'm not going to answer your question about how to create a sidebar  
> for your layout. Address that to a forum for web design. Hopefully you  
> understand that once you have your HTML mocked up with your sidebar,  
> that you would use xslt to make it dynamic. I'm not convince you've  
> understood me on the xslt front - mainly because I don't see that  
> you've used it.
>
> -geoff
>
> ...
>
> read more »

Geoffrey Hendrey

unread,
Dec 7, 2009, 9:24:08 PM12/7/09
to nextd...@googlegroups.com
Sounds like I need to make a wiki page for nextdb+xslt. I'll work on
that tonight - I think it would benefit everyone.

Sent from my iPhone

Eric Dorman

unread,
Dec 7, 2009, 9:46:47 PM12/7/09
to NextDB Users
Hey Geoff,

I tried to enter XSLT template and HTML into the email trigger
textarea.

Is that were you enter the html under the Email Trigger Tab?

Oh, and I have found a great resource for XSLT which is here below.

http://www.w3schools.com/xsl/


I'd really like that if you made a wiki page about that and maybe a
video. :)

I don't know just thought i'd throw suggestion in their. :)

God Bless,
Eric

On Dec 7, 9:24 pm, Geoffrey Hendrey <geoff.hend...@gmail.com> wrote:
> Sounds like I need to make a wiki page for nextdb+xslt. I'll work on  
> that tonight - I think it would benefit everyone.
>
> Sent from my iPhone
>
> ...
>
> read more »

geoffrey hendrey

unread,
Dec 8, 2009, 2:39:33 AM12/8/09
to nextd...@googlegroups.com
Hi Eric,

I've beefed up the wiki on XSLT and included some better examples.

http://www.nextdb.net/wiki/en/REST#XSLT_%28reformatting_your_data%27s_presentation%29

I'd appreciate your feedback on this section, and I'd like you to take a second try at making an XSLT based on this documentation I've created.

-geoff

To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


Eric Dorman

unread,
Dec 8, 2009, 2:36:49 PM12/8/09
to NextDB Users
Hey Geoff,

Wow that's some great documentation,but you said in the docs that I
store an XSLT File in Nextdb.

Were do I go to store my XSLT File?

Do you make a new table like you said and insert a table called
transformations or something like that?

All around I like it a lot and have you ever thought the REST Feature
could be kind of used to host apps in the cloud for customers is they
don't have their own host?

Just an idea. :)

Thanks & God Bless,
Eric

On Dec 8, 2:39 am, geoffrey hendrey <geoff.hend...@gmail.com> wrote:
> Hi Eric,
>
> I've beefed up the wiki on XSLT and included some better examples.
>
> http://www.nextdb.net/wiki/en/REST#XSLT_%28reformatting_your_data%27s...
>
> I'd appreciate your feedback on this section, and I'd like you to take a
> second try at making an XSLT based on this documentation I've created.
>
> -geoff
>
> ...
>
> read more »

geoffrey hendrey

unread,
Dec 8, 2009, 9:47:02 PM12/8/09
to nextd...@googlegroups.com
Correct - if you want to store the XSLT in nextdb, you create a table, for instance "CONFIG_FILES" and then add a column of type TEXT named 'transforms'. Of course you can pick any name you like for the table and column.

Then you just insert your XSLT into the column. I do this just by cut-and-paste using the admin UI.

Once you have done that, you can refer to the column's content via a URL. This is described in this wiki topic about getting values like text files and images from columns:  http://www.nextdb.net/wiki/en/REST#Accessing_Content_From_a_Single_Column

> ...
>
> read more »

--

You received this message because you are subscribed to the Google Groups "NextDB Users" group.
To post to this group, send email to nextd...@googlegroups.com.
To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


Eric Dorman

unread,
Dec 9, 2009, 1:28:43 AM12/9/09
to NextDB Users
So I can retrieve my KSLT url using a column?

Ok now I think I am starting to get it down . Can you use a column
value to retrieve a url or a html url that has html data within the
url?

Maybe I can retrieve a url that has html in the file like for example
test.html and have it show up in my column.

Thanks & God Bless,
Eric

On Dec 8, 9:47 pm, geoffrey hendrey <geoff.hend...@gmail.com> wrote:
> Correct - if you want to store the XSLT in nextdb, you create a table, for
> instance "CONFIG_FILES" and then add a column of type TEXT named
> 'transforms'. Of course you can pick any name you like for the table and
> column.
>
> Then you just insert your XSLT into the column. I do this just by
> cut-and-paste using the admin UI.
>
> Once you have done that, you can refer to the column's content via a URL.
> This is described in this wiki topic about getting values like text files
> and images from columns:http://www.nextdb.net/wiki/en/REST#Accessing_Content_From_a_Single_Co...
> ...
>
> read more »

geoffrey hendrey

unread,
Dec 9, 2009, 1:49:21 AM12/9/09
to nextd...@googlegroups.com
Your getting warmer.

Give the wiki pages another read.

It's actually really simple. Nextdb takes your XSLT file and uses it to transform the HTML that the REST stuff serves.

In order to get your XSLT file, nextdb needs to have a URL that it can download the file from. NextDB doesn't care where the URL points to. Could be an XSLT file on "mysite.com", or some fileserver somewhere, or stored in NextDB. If you decide to store your XSLT in nextdb, one way to do it is, as described on the wiki, where we created a table called CONFIG_FILES with a column called transforms.

http://nextdb.net/nextdb/rest/geoff/testchars/CONFIG_FILES/row/1/transforms.xslt

I think if you follow the detailed explanation on the wiki, that you will figure it out.

-geoff




> ...
>
> read more »

--

You received this message because you are subscribed to the Google Groups "NextDB Users" group.
To post to this group, send email to nextd...@googlegroups.com.
To unsubscribe from this group, send email to nextdb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nextdb-user?hl=en.


Reply all
Reply to author
Forward
0 new messages