Hi all
Can anyone tell me how to achieve this? I want to be able to add previous / next links - like you would find on a blog - to be able to cycle through LISE entries.
I've found this article: https://cmscanbesimple.org/blog/adding- ... tail-pages
But struggling to work out how to apply not to LISE! Has anyone done this before and wouldn't mind sharing code?
Thanks!
LISE - add previous/next links Topic is solved
-
- Forum Members
- Posts: 192
- Joined: Mon Nov 26, 2018 3:09 pm
Re: LISE - add previous/next links
I think it would involve:
- assign current item_id to a variable
- call LISE again (summary action) and inside the summary template loop through all items, assigning previous item_id and moreurl to variables, comparing current item_id with previously saved item_id.
- if current item_id == saved item_id then you should somehow save (or print) the moreurl of the previous item.
- then loop once more to get the next item's moreurl
- special care should be taken if item is the first or last
- note that the $item variable from the summary action may overwrite the $item variable of your detail action/template.
Also think about sorting/ordering if you use any.
- assign current item_id to a variable
- call LISE again (summary action) and inside the summary template loop through all items, assigning previous item_id and moreurl to variables, comparing current item_id with previously saved item_id.
- if current item_id == saved item_id then you should somehow save (or print) the moreurl of the previous item.
- then loop once more to get the next item's moreurl
- special care should be taken if item is the first or last
- note that the $item variable from the summary action may overwrite the $item variable of your detail action/template.
Also think about sorting/ordering if you use any.
-
- Forum Members
- Posts: 192
- Joined: Mon Nov 26, 2018 3:09 pm
Re: LISE - add previous/next links
Thanks Velden! This sounds a bit more complicated than my meagre smarty skills though!
If anyone happens to have already done this and can share code I'd be really grateful! I guess my other option could be to modify CGBlog to my needs, I assume that has prev/next links...
Thanks
If anyone happens to have already done this and can share code I'd be really grateful! I guess my other option could be to modify CGBlog to my needs, I assume that has prev/next links...
Thanks
Re: LISE - add previous/next links
Have you looked at how the News does it..?
-
- Forum Members
- Posts: 192
- Joined: Mon Nov 26, 2018 3:09 pm
Re: LISE - add previous/next links
I dont think News does have a next/previous article link?
Re: LISE - add previous/next links
Sometimes you just need to start and try. As I probably need it soon in one of my projects I've made an example.
As you can see it's not difficult. Try to understand the code and learn that CMSMS and Smarty offer so much flexibility. It's just limited by your imagination.
Obviously code can/should be changed to suit your needs. This is just a proof of concept.
LISE summary template 'nextprevlinks':
LISE detail template where you want to have the prev/next links:
Note that if you use the orderby/filter/category parameter somewhere you need to use it here too of course.
As you can see it's not difficult. Try to understand the code and learn that CMSMS and Smarty offer so much flexibility. It's just limited by your imagination.
Obviously code can/should be changed to suit your needs. This is just a proof of concept.
LISE summary template 'nextprevlinks':
Code: Select all
{if $items|@count > 0}
{$prev_url=''}
{$i_am_next=false}
{foreach from=$items item=item}
{if $i_am_next}
<a href="{$item->url}">NEXT ITEM</a>
{break}
{/if}
{if $item->item_id == $current_item_id}
{$i_am_next=true}
{if !empty($prev_url)}
<a href="{$prev_url}">PREVIOUS ITEM</a>
{/if}
{else}
{$prev_url=$item->url}
{/if}
{/foreach}
{/if}
Code: Select all
{$current_item_id=$item->item_id}
{LISEnextprev template_summary=nextprevlinks}
-
- Forum Members
- Posts: 192
- Joined: Mon Nov 26, 2018 3:09 pm
Re: LISE - add previous/next links
Thanks Velden - believe me, I have been trying...but failing! Many thanks for this, I will take a look and see what I can make of it
I only do 'front-end' really, hence my struggle with programming
j
I only do 'front-end' really, hence my struggle with programming
j
-
- Forum Members
- Posts: 192
- Joined: Mon Nov 26, 2018 3:09 pm
Re: LISE - add previous/next links - SOLVED
Hi Velden
This works perfectly - just wanted to say a big thank you! I was messing around with this for hours, you made it look so simple!
This works perfectly - just wanted to say a big thank you! I was messing around with this for hours, you made it look so simple!