hi,

i've test the pagination from : 
http://web2py.com/book/default/chapter/12?search=pagination#Pagination
and tried to change the next and previous that on view into the
controller

e.g.
from view:
{{if page:}}
<a href="{{=URL(args=[page-1])}}">previous</a>
{{pass}}

{{if len(rows)>items_per_page:}}
<a href="{{=URL(args=[page+1])}}">next</a>
{{pass}}

into controller:
def list_items():
    if len(request.args): page=int(request.args[0])
    else: page=0
    items_per_page=20
    limitby=(page*items_per_page,(page+1)*items_per_page+1)
    rows=db().select(db.prime.ALL,limitby=limitby)
    if page:
        previous = "<a href="{{=URL(args=[page-1])}}">previous</a>"

    if len(rows)>items_per_page:
        next = "<a href="{{=URL(args=[page+1])}}">next</a>"
    return
dict(rows=rows,page=page,items_per_page=items_per_page,previous=previous,next=next)


but returned an error, is there any solution for this?
thank you very much before

Reply via email to