1. Wednesday, October 01 2008 21:26pagination !

    references: pseudo sql, unknown

    Easy to use pagination at last !

    I won’t rewrite all the documentation here, but I’ll give you a small example. See context and link for the details.

    <r:posts in='site' limit='10' paginate='p'>
    <ul>
      <li do='each' do='link'/>
    </ul>
    <r:link page='previous'/> <!-- link to previous page -->
    <r:show var='p'/>         <!-- display current page number -->
    <r:link page='next'/>     <!-- link to next page -->
    </r:posts>
    

    As you can see, the link tag is inside the posts context. This is why it knows about the pagination key “p” and how to show previous/next pages.

    The page size is simply defined by the limit clause of the posts context.

    You can display page numbers and use ajax too:

    <div id='recent_news' do='block' do='notes' in='site' order='log_at desc' limit='5' paginate='lp'>
      <r:link page='list' update='recent_news'/>
      <ul>
        <li do='each'><span class='date' do='show' date='log_at' tformat='short_date'/> <r:link/></li>
      </ul>
    </div>

    PS for a real world example, look at the bottom of the blog’s main page !

    PPS it’s fun to look back at the original ideas for zafu or other topics: 2007 archives.

    Gaspard Bucher

    comments

    1. leave a comment