Jump to content

[MODULE] Product ratings on category list (PS 1.5)


jgullstr
 Share

Recommended Posts

Per El Patron's request, I decided to post this here. Don't think there's much demand for such a narrow feature as this, but new developers can check the source for an  example of registering your own smarty functions, enforcing module dependencies and rendering templates within a module.

 

Instruction after install:
Add {rating id=$product.id_product} where you want the stars to appear in your product-list.tpl.
 
Tip:
If you for any reason want to put the module on some other page where the product object is accessible, you can modify the displayHeader hook's condition to support that controller.

categorylistratings.zip

  • Like 1

Share this post


Link to post
Share on other sites

  • 1 month later...

Nice module! Do you know what code to add to prevent stars from showing if there are no reviews? 

Also, would you consider extending this so that we can show reviews in the left column?

Thanks!!

EDIT:

Hi guys,

Here's a free module to display comments in the left column...

http://www.prestashop.com/forums/topic/128975-module-block-latest-comments/

Edited by Cari (see edit history)

Share this post


Link to post
Share on other sites

Nice module! Do you know what code to add to prevent stars from showing if there are no reviews? 

Also, would you consider extending this so that we can show reviews in the left column?

Thanks!!

 

To hide zero star results, you will have to modify your stars.tpl file as follows:

{if $average_total >= 1}
  (old content)
{/if} 

I have no plans on extending this module.

Edited by jgullstr (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 2 months later...

Hi, I get empty page when i disable and delete cache and smarty files. I get below error reporting. I run ps 1.5.6.1

 

Any ideas how to solve this?

 

Further investigation show this is error is caused by this: if($this->context->controller->php_self == 'category'){

 

Since I run with friendly URL enabled the controller=category is not in the url link anymore.

How can this problem be solved to make this module work with friendly URL? Can i just remove this line without causing other issues somewhere else?

 

I Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:\xampp\htdocs\presta1550\themes\alysum_2.0divine\product-list.tpl" on line 71 "<div class="product-info">{rating id=$product.id_product}" unknown tag "rating"' in C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php:667 Stack trace: #0 C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php(453): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "ra...', 71) #1 C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templateparser.php(2388): Smarty_Internal_TemplateCompilerBase->compileTag('rating', Array) #2 C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templateparser.php(3101): Smarty_Internal_Templateparser->yy_r36() #3 C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templateparser.php(3201): Smarty_Internal_Templateparser->yy_ in C:\xampp\htdocs\presta1550\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667

Edited by Alexgaw (see edit history)

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 5 months later...
{if $average_total >= 1}
  (old content)
{/if} 

 

Where I place the code in the tpl??

 

 

 

<div class="star_content clearfix">

 

{section name="i" start=0 loop=5 step=1}

 

    {if $smarty.section.i.index lt $average_total}

 

        <div class="star star_on"><a href=""></a></div>

 

    {else}

 

        <div class="star"><a href=""></a></div>         

 

    {/if}

 

{/section}

 

</div>

 

 

It can be put in homefeatured module????

 

Thanks!

Edited by CHP (see edit history)

Share this post


Link to post
Share on other sites

  • 4 months later...

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "C:\xampp\htdocs\cartbiz\modules\homefeatured\views\templates\hook\productsblock.tpl" on line 64 "{rating id=$product.id_product}" unknown tag "rating" <-- thrown in C:\xampp\htdocs\cartbiz\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 64

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 2 months later...
Hi,

 

Thank you for offering the free module to add rating to product list on Prestashop.

 

Such module allows the display of the number of stars for each item on the product list page.

 

Would you know how to also display the number of comments for each item on the product list page ?

 

My shop is built with Prestashop 1.5.6.2.

 

Thank you in advance for any reply.

 

Kind Regards,

 

Patrick

Share this post


Link to post
Share on other sites

  • 1 year later...

Hello,

I'm trying to display products stars ratings on the product list

My prestashop version is 1.6.1.6

I have tried this module and it does not work correctly.

I'm getting a white page...

 

I also see these lines in product_list.tpl:

 

                    {capture name='displayProductListReviews'}{hook h='displayProductListReviews' product=$product}{/capture}
                    {if $smarty.capture.displayProductListReviews}
                        <div class="hook-reviews">
                        {hook h='displayProductListReviews' product=$product}
                        </div>
                    {/if}

 

I believe that the function is already there but I cannot find where to activate it

 

Does someone knows how to do it?

 

Thank you.

Regards

Edited by StefArts (see edit history)

Share this post


Link to post
Share on other sites

  • 6 months later...

Hello, 

 

The module prevents the layered navigation to work.

 

The error message is the following :

PHP Fatal error:  Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/product-list.tpl"  on line 105 "{rating id=$product.id_product}" unknown tag "rating"

 

Did anyone find the way to solve the matter ?

 

Thank you in advance,

 

Patrick

Share this post


Link to post
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More