I followed the pagination tutorial in the web2py book and I have the 
following controller:

def index():
    if len(request.args): page=int(request.args[0])
    else: page=0
    items_per_page=6
    limitby=(page*items_per_page,(page+1)*items_per_page+1)
    posts=db().select(db.post.ALL, orderby=~db.post.date, limitby=limitby)
    return dict(posts=posts, page=page, items_per_page=items_per_page)

...and this view controlling navigation:

<div class="pagination pagination-centered">
  <ul>
    {{if page:}}
    <li><a href="{{=URL(args=[page-1])}}">Prev</a></li>
    {{pass}}
    {{if len(posts)>items_per_page:}}
    <li><a href="{{=URL(args=[page+1])}}">Next</a></li>
    {{pass}}
  </ul>
</div>

The only problem I have with it is when you go to the second page it 
reports as page 1. I would like the first page to be page 1. Is that 
possible without completely rewriting the pagination function?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to