LISE - add previous/next links Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

LISE - add previous/next links

Post by johnboyuk1 »

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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE - add previous/next links

Post by velden »

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.
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE - add previous/next links

Post by johnboyuk1 »

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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: LISE - add previous/next links

Post by Dr.CSS »

Have you looked at how the News does it..?
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE - add previous/next links

Post by johnboyuk1 »

I dont think News does have a next/previous article link?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE - add previous/next links

Post by velden »

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':

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}
LISE detail template where you want to have the prev/next links:

Code: Select all

{$current_item_id=$item->item_id}
{LISEnextprev template_summary=nextprevlinks}
Note that if you use the orderby/filter/category parameter somewhere you need to use it here too of course.
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE - add previous/next links

Post by johnboyuk1 »

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
johnboyuk1
Forum Members
Forum Members
Posts: 192
Joined: Mon Nov 26, 2018 3:09 pm

Re: LISE - add previous/next links - SOLVED

Post by johnboyuk1 »

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!
Locked

Return to “Modules/Add-Ons”