ListIt2 link to next and previous items

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Locked
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

ListIt2 link to next and previous items

Post by blackrain »

I've been looking for some time for and answer to this problem. ordinarily I think pagination would be the answer but I don't want to use the summary mechanism in ListIt2 to render the items but to goto the next item in the list in the detail view.

Is this possible in the same way that CMSMS has a native next /previous page function.

I am using CMSMS 1.12.3

many thanks
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: ListIt2 link to next and previous items

Post by Rolf »

Never used it in ListIt modules, but perhaps worth a try
http://www.cmscanbesimple.org/blog/cmsm ... -scrolling
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: ListIt2 link to next and previous items

Post by blackrain »

Not really the solution I am looking for, as I want to goto the next item on a new page, I have used scrolling before to stack the list like a carousel but in this case there are lot of assets attached to each listing and need to separate for SEO purposes.

thanks for the suggestion though Rolf.


Mark
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: ListIt2 link to next and previous items

Post by velden »

What's your problem using the summary view for this purpose? (beside the fact that it might be less efficient)

(Note you may be able to use the summary in your detail template too)
blackrain
Forum Members
Forum Members
Posts: 98
Joined: Wed Feb 20, 2008 4:33 pm

Re: ListIt2 link to next and previous items

Post by blackrain »

not sure how to go about achieving that, nice idea as that would solve the issue of no next/previous links for the details pages. how would i inform the summary template to use another summary template for the details page. any thoughts?

thanks

Mark
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: ListIt2 link to next and previous items

Post by velden »

[update Jan 2018] Please read this post too: viewtopic.php?p=336718#p336718

I mean like this:

I added this part at the end of the DETAIL template of LI2.
Note that my LI2 instance is named 'ListIt2test'. Of course you use the name of your instance.

Tested on CMSMS 1.12.1, LI2 1.4.1

Note that

Code: Select all

{$current_id = $item->item_id}

{*call LI2 summary action with empty summary template.
Just to get $items variable. May NOT work in later versions of CMSMS
Tested on CMSMS 1.12.1 / LI2 1.4.1*}	
{ListIt2test summarytemplate=next_prev assign=dummy}
{foreach $items as $sumitem}
  {if $sumitem->item_id == $current_id}
  {$iteration=$sumitem@iteration}
    {if $iteration > 1}{$prev_link = $items[$iteration-1]->url}{/if}
{if $iteration < $sumitem@total}{$next_link = $items[$iteration+1]->url}{/if}
  {break}
  {/if}
{/foreach}
<div class="next-prev">
{if isset($prev_link)}<a href="{$prev_link}">Previous item</a><br>{/if}
{if isset($next_link)}<a href="{$next_link}">Next item</a><br>}{/if}
</div>
LI2 SUMMARY template 'next_prev':

Code: Select all

{*nothing here*}
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: ListIt2 link to next and previous items

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: ListIt2 link to next and previous items

Post by velden »

I think I should add one note for both my solution and Rolf's (which are mostly doing the same):

IF you call the INITIAL summary action with some kind of 'filtering' (e.g. category=x) then it would be important to use that same 'filter' when calling the summary action for the prev/next links.

However, I doubt (don't know for sure) that those initial 'filters' are available in the detail action. If they indeed are NOT available in the detail action (template) then you should think of some smart things to work around that, or just hard code them in the detail template.
Locked

Return to “The Lounge”