We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Previous and next button to go to the next active id | Forum

Ken
Ken Nov 2 '20
Put a Previous and next button to go to the next active id on view page

<input style='float:left' type="button" class="prev-btn" name="b1" value="prev" onclick="location.href='/item/view/{$item->id-1}'">
<input style='float:right' type="button" class="next-btn" name="b2" value="next" onclick="location.href='/item/view/{$item->id+1}'">

This works but If next number id missing it will give an error 
How to rewrite this to go to next or previous only active id item...


href='/item/view/{$item->id+1}

Any simple suggestions????
dave Leader
dave Nov 28 '20

try wrapping your next button with an if, untested but youll get the idea


something like


{if $item->id+1}

<input style='float:right' type="button" class="next-btn" name="b2" value="next" onclick="location.href='/item/view/{$item->id+1}'">

{/if}


you may have to qualify it but not sure something like


{if $item->id+1 eq whatever}  whatever that value might be, null 0 im not sure what it would be in your case.


in smarty you can use  eq for =   ne for !=   gt  for >   amd   lt for < 

equals notequals greaterthan lessthan



Ken
Ken Dec 6 '20
I used {if count($nextitem) > 0 }
The Forum post is edited by Ken Dec 6 '20
REHMAN
REHMAN Apr 19
Are not they in a hurry? Do not they want to find the outpost? Need not Kirk get back to the ship? Yet they sit there, having a talk and barbecue around a log fire. tydo88
REHMAN
REHMAN Apr 19
Are not they in a hurry? Do not they want to find the outpost? Need not Kirk get back to the ship? Yet they sit there, having a talk and barbecue around a log fire. tydo88
REHMAN
REHMAN Apr 19
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks. kids smartwatch
REHMAN
REHMAN Apr 19
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks. kids smartwatch
REHMAN
REHMAN Apr 25
This phenomenal hearings thoroughly correct. Most of low statistics are prepared by making usage of large number about feel effective skills. We're anxious the software once a whole lot. natraj pencil packing job