CMS Made Simple Forums
https://forum.cmsmadesimple.org/

LisIt2 pagination limit
https://forum.cmsmadesimple.org/viewtopic.php?f=7&t=82245
Page 1 of 1

Author:  jakovbak [ Fri May 22, 2020 8:17 am ]
Post subject:  LisIt2 pagination limit

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:

\$1:
      {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!

Author:  velden [ Fri May 22, 2020 11:27 am ]
Post subject:  Re: LisIt2 pagination limit  Topic is solved

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.

\$1:
{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}

Author:  jakovbak [ Fri May 22, 2020 11:42 am ]
Post subject:  Re: LisIt2 pagination limit [SOLVED]

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

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/