My code for the pagination (next button)

 <a 
href="{{=URL(vars={'page':int(request.vars.page)+1,'name':request.var.name})}}">Next</a>

If there is a name, it will add it to the url however if there is no name, 
it will add "none". Instead if it doesn't exist I don't want it to add 
anything, just the page.

On Thursday, 30 March 2017 16:34:28 UTC+1, Anthony wrote:
>
> It is not quite clear what you are asking. Please show some code.
>
> Anthony
>
> On Thursday, March 30, 2017 at 10:41:50 AM UTC-4, r wrote:
>>
>> Hi, so my index page is like this: /index?page=1 I'm using pagination, 
>> when the user clicks on the next page, it should become: /index?page=2
>>
>> However if there is another var in the URL, it should carry that too
>>
>> /index?page=1&name=test 
>> becomes 
>> /index?page=2&name=test
>>
>> At the moment, I've done in a way where even if "name" doesn't exist, it 
>> will add it to the url anyway equalling "none" (from request.vars.name).
>> /index?page=1 
>> becomes
>> /index?page=2&name=none
>>
>> Is there any way to only add the var if it does exist? 
>>
>> This was a basic example, there are in fact 5 different vars in my real 
>> version, the only way I can think of is creating many IF statements. 
>> Anything simpler? 
>>
>

-- 
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/d/optout.

Reply via email to