Jump to content

[SOLVED]Modify pagination - show all pages


Recommended Posts

Now Prestashop pagination works like this:

1) « Previous 1 2 3 Next » (When category is loaded or user press link 1)
2) « Previous 1 2 3 4 Next » (When user select 2 or 3 link)
3) « Previous 2 3 4 Next » (When last link 4 is selected)

Is it possible to modify pagination, in order what all pages always will be visible. No matter you select link 1, 2, .., last one

I think answer is somewhere here :)

>{if $start!=$stop}
</pre>
<ul>
       {if $p != 1}
           {assign var='p_previous' value=$p-1}
goPage($requestPage, $p_previous)}">« {l s='Previous'}
       {else}
« {l s='Previous'}
       {/if}
       {if $start>3}
goPage($requestPage, 1)}">1
...
       {/if}
       {section name=pagination start=$start loop=$stop+1 step=1}
           {if $p == $smarty.section.pagination.index}
{$p|escape:'htmlall':'UTF-8'}
           {else}
goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}
           {/if}
       {/section}
       {if $pages_nb>$stop+2}
...
goPage($requestPage, $pages_nb)}">{$pages_nb|intval}
       {/if}
       {if $pages_nb > 1 AND $p != $pages_nb}
           {assign var='p_next' value=$p+1}
goPage($requestPage, $p_next)}">{l s='Next'} »
       {else}
{l s='Next'} »
       {/if}
</ul>
<br>   {/if

Link to comment
Share on other sites

Change line 7 of pagination.php (in PrestaShop v1.3.2):

$range = 2; /* how many pages around page selected */



By default, PrestaShop will display only 2 pages either side of the current page. Increase this to a bigger value so that all pages are displayed.

Link to comment
Share on other sites

  • 4 months later...

I know this topic is kinda old, but...

I had this working at one point, but then i just discovered that it is back to where i started, im not sure but i think i changed back when updating to 1.3.6, range = 15 at our shop, but i stille have this issue.

Link to comment
Share on other sites

  • 5 months later...
  • 3 months later...

Hello, I wrote a small article with fixed pagination.tpl, but it's in Russian. http://blog.kfedorov...l-v-prestashop/

or simply use the code part highlighted yellow from that article.

 

This is the code with fix + new code separated with spaces:

{if $start!=$stop}
<ul class="pagination">
{if $p != 1}
 {assign var='p_previous' value=$p-1}
 <li id="pagination_previous"><a href="{$link->goPage($requestPage, $p_previous)}">« {l s='Previous'}</a></li>
{else}
 <li id="pagination_previous" class="disabled"><span>« {l s='Previous'}</span></li>
{/if}



{if $start-$range<$range}
 {section name=pagination_start start=1 loop=$start step=1}
  <li><a href="{$link->goPage($requestPage, $smarty.section.pagination_start.index)}">{$smarty.section.pagination_start.index|escape:'htmlall':'UTF-8'}</a></li>
 {/section}
{/if}



{if $start>3}
 <li><a href="{$link->goPage($requestPage, 1)}">1</a></li>
 <li class="truncate">...</li>
{/if}
{section name=pagination start=$start loop=$stop+1 step=1}
 {if $p == $smarty.section.pagination.index}
  <li class="current"><span>{$p|escape:'htmlall':'UTF-8'}</span></li>
 {else}
  <li><a href="{$link->goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li>
 {/if}
{/section}
{if $pages_nb>$stop+2}
 <li class="truncate">...</li>
 <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li>
{/if}



{if $stop+$range>$pages_nb-1}
 {section name=pagination_start start=$stop+1 loop=$pages_nb+1 step=1}
  <li><a href="{$link->goPage($requestPage, $smarty.section.pagination_start.index)}">{$smarty.section.pagination_start.index|escape:'htmlall':'UTF-8'}</a></li>
 {/section}
{/if}



{if $pages_nb > 1 AND $p != $pages_nb}
 {assign var='p_next' value=$p+1}
 <li id="pagination_next"><a href="{$link->goPage($requestPage, $p_next)}">{l s='Next'} »</a></li>
{else}
 <li id="pagination_next" class="disabled"><span>{l s='Next'} »</span></li>
{/if}
</ul>
{/if}

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
×
×
  • Create New...