Jump to content

Set Product Comments per Page with Pagination


Peter_Jansen

Recommended Posts

Hello Community,

 

 

I don't have enough php knowledge, maybe you gurus can help me out ;-)

 

I have modified the Product Comment Module to my needs and I implemented the original Pagination from Prestashop. The pagination is now visible in the comment section in the idTab5.

 

I need to write a function that it shows only 10 comments in the table and if there are more than 10 comments go to page 2 in the pagination. Another problem with the pagination is, that when I click on page 2 it just reloads the productsite but it doesn't jump to comments but instead to the default "more info" tab...

 

Here is the function for the pagination that is implemented in the productcomments.tpl :

 

<!-- Pagination -->

{if isset($p) AND $p}

{if isset($smarty.get.id_product_comment) && $smarty.get.id_product_comment && isset($comments)}

{assign var='requestPage' value=$link->getPaginationLink('id_product_comment', $comments, false, false, true, false)}

{assign var='requestNb' value=$link->getPaginationLink('id_product_comment', $comments, true, false, false, true)}

{else}

{assign var='requestPage' value=$link->getPaginationLink(false, false, false, false, true, false)}

{assign var='requestNb' value=$link->getPaginationLink(false, false, true, false, false, true)}

{/if}

 

<div id="pagination" class="pagination">

{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=''}</a></li>

{else}

<li id="pagination_previous" class="disabled"><span>« {l s=''}</span></li>

{/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 $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=''} »</a></li>

{else}

<li id="pagination_next" class="disabled"><span>{l s=''} »</span></li>

{/if}

</ul>

{/if}

{if $nbComments > 6}

<form action="{if !is_array($requestNb)}{$requestNb}{else}{$requestNb.requestUrl}{/if}" method="get" class="pagination">

<p>

{if isset($search_query) AND $search_query}<input type="hidden" name="search_query" value="{$search_query|escape:'htmlall':'UTF-8'}" />{/if}

{if isset($tag) AND $tag AND !is_array($tag)}<input type="hidden" name="tag" value="{$tag|escape:'htmlall':'UTF-8'}" />{/if}

<input type="submit" class="button_mini" value="{l s='OK'}" />

<label for="nb_item">{l s='items:'}</label>

<select name="n" id="nb_item">

{assign var="lastnValue" value="0"}

{foreach from=$nArray item=nValue}

{if $lastnValue <= $nbComments}

<option value="{$nValue|escape:'htmlall':'UTF-8'}" {if $n == $nValue}selected="selected"{/if}>{$nValue|escape:'htmlall':'UTF-8'}</option>

{/if}

{assign var="lastnValue" value=$nValue}

{/foreach}

</select>

{if is_array($requestNb)}

{foreach from=$requestNb item=requestValue key=requestKey}

{if $requestKey != 'requestUrl'}

<input type="hidden" name="{$requestKey|escape:'htmlall':'UTF-8'}" value="{$requestValue|escape:'htmlall':'UTF-8'}" />

{/if}

{/foreach}

{/if}

</p>

</form>

{/if}

</div>

<!-- /Pagination -->

{/if}

 

 

This doesn't seem to properly work, I don't know where the problem is... I think I need to write the function for the 10 comments per page in the productcomments.php . Anyone know how to write the function?

 

Thank you very much!

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...