Page 1 of 1
ListIt2 link to next and previous items
Posted: Mon Apr 04, 2016 2:32 pm
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
Re: ListIt2 link to next and previous items
Posted: Mon Apr 04, 2016 4:20 pm
by Rolf
Never used it in ListIt modules, but perhaps worth a try
http://www.cmscanbesimple.org/blog/cmsm ... -scrolling
Re: ListIt2 link to next and previous items
Posted: Thu Apr 14, 2016 7:55 am
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
Re: ListIt2 link to next and previous items
Posted: Thu Apr 14, 2016 11:10 am
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)
Re: ListIt2 link to next and previous items
Posted: Fri Apr 15, 2016 11:39 am
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
Re: ListIt2 link to next and previous items
Posted: Fri Apr 15, 2016 3:27 pm
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':
Re: ListIt2 link to next and previous items
Posted: Fri Apr 15, 2016 9:13 pm
by Rolf
Re: ListIt2 link to next and previous items
Posted: Sat Apr 16, 2016 11:31 am
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.