LisIt2 pagination limit

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
jakovbak
Forum Members
Forum Members
Posts: 200
Joined: Thu Dec 13, 2012 2:54 pm

LisIt2 pagination limit

Post by jakovbak »

Hello everyone!
How could I limit the number of ListIt2 summary pagination? Right now a page contains 86 items and it's way too much. I would like to reduce it to something like:

< << 1 2 3 4 5 6 7 >> >

The pagination code is:

Code: Select all

		{if $pagecount > 1}
			<p>
				{if $pagenumber > 1}
					{$firstpage}&nbsp;{$prevpage}&nbsp;
				{/if}

				{foreach from=$pagelinks item=page}
					&nbsp;{$page->link}&nbsp;&nbsp;
				{/foreach}

				{if $pagenumber < $pagecount}
					&nbsp;{$nextpage}&nbsp;{$lastpage}
				{/if}
			</p>
		{/if}
I simply suck when it comes to tweaking code so I would appreciate any kind of help or hint! ;D
Thank you in advance and have a great weekend y'all!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3293
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LisIt2 pagination limit

Post by velden »

Hope you're talking about LISE (ListIt2 is old).

The first, previous, next and last urls are not a problem I presume.

The numbers are a little more difficult but doable. Your example shows 7 numbers so I'll use it too.

Further I added some ellipsis to show before and/or after the page numbers. Of course that's optional.

Code: Select all

{if $pagecount > 1}
 <p>
	{if $pagenumber > 1}
	   {$firstpage}&nbsp;{$prevpage}&nbsp;
	{/if}
			
{* number of pages to show = 7. So if possible current page, 3 before, 3 after *}
{$before=''}{* used for ellipsis *}
{$after=''}{* used for ellipsis *}
{if $pagecount <= 7}
  {$from = 1}{$to = $pagecount}
{else}
  {if $pagenumber <= 3}
    {$from = 1}{$to = 7}
    {if $pagecount > 7}{$after='&hellip;'}{/if}
  {elseif $pagecount - $pagenumber <= 3}
    {$from = $pagecount - 6}{$to = $pagecount}
    {if $pagecount > 7}{$before='&hellip;'}{/if}
  {else}
    {$from = $pagenumber - 3}{$to = $pagenumber + 3}   
    {if $pagecount > 7}{$before='&hellip;'}{$after='&hellip;'}{/if}
  {/if}
{/if}
{$before}
	{for $i = $from to $to}
	  <a{if $i == $pagenumber} class="current"{else} href="{$pagelinks[$i]->url}"{/if}>{$i}</a>
	{/for}
{$after}

	{if $pagenumber < $pagecount}
	   &nbsp;{$nextpage}&nbsp;{$lastpage}
	{/if}
 </p>
{/if}
jakovbak
Forum Members
Forum Members
Posts: 200
Joined: Thu Dec 13, 2012 2:54 pm

Re: LisIt2 pagination limit [SOLVED]

Post by jakovbak »

Dear Velden!
Thank you for your post, it's working solution right out of the box! ;D
I have already tested it and it works like a charm.
I know ListIt2 is old but so is the site I was taking care of. Over the years it grew up very big but I was denied whenever I suggested to do upgrade and, if necessary, a make-over. Until now... They just contacted me a few days ago to discuss my proposal but also to ask if it's possible to make some minor tweaks (like favicon and BS like that). Among that was this case but hopefully, in the near future I'll finally move it all to the latest version of CMSMS. Fortunately, LISE can import old ListIt2 items and hopefully there won't be too much trouble to transfer it.
Thank you very much for helping me out with this, hope you are ok and keep safe and healthy!
Best regards from Croatia ;D
Locked

Return to “Modules/Add-Ons”