X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Mod: Display number of reviews (https://forum.x-cart.com/showthread.php?t=5055)

BoomBoomBap 11-02-2003 07:33 PM

Mod: Display number of reviews
 
I was looking to find a way to display the number of reviews and reached this post: http://forum.x-cart.com/viewtopic.php?t=2292 - which shows how to display the number of votes

Taking off from this idea I made the following mod:

In customer/vote.php add the following code:

Code:

###################
//display total reviews
        $reviews_result = func_query_first ("SELECT COUNT(remote_ip) as total FROM $sql_tbl[product_reviews] WHERE productid='$productid'");

        if ($reviews_result["total"] == 0)
        $smarty->assign ("reviews_result", $reviews_result);
  $smarty->assign ("reviews_total", $reviews_result["total"]);
###################


and then in skin1/customer/Modules/Customer_Reviews/reviews.tpl add the following code where you want to display the number:

Code:

{$reviews_total}


Personally I placed it here:
Code:

{$reviews_total} {$lng.lbl_customer_reviews}

This shows something like "11 Customer Reviews"

Neat !


Next I'd like to limit the number of reviews shown to 5 and then "click here to display all"

BoomBoomBap 11-02-2003 08:32 PM

Okay, I've figured out how to limit the number of reviews displayed and then have a link to show all.

In customer/vote.php find this:

Code:

$reviews = func_query ("SELECT * FROM $sql_tbl[product_reviews] WHERE productid='$productid'");

replace with this:

Code:

//for showing all reviews
        if ($show_all_reviews == yes) {
        $reviews = func_query ("SELECT * FROM $sql_tbl[product_reviews] WHERE productid='$productid'");
} else {       
        $reviews = func_query ("SELECT * FROM $sql_tbl[product_reviews] WHERE productid='$productid' LIMIT 5");
}
// change the LIMIT number to display less or more reviews
// end


Then, in skin1/modules/Customer_Reviews/vote.tpl add this:


If you have NOT used the mod listed in the first post then remove
Code:

({$reviews_total} total)
and this part of the mod should still work.

funkydunk 11-02-2003 09:48 PM

Great mod :)

ghhoz 01-04-2005 06:23 PM

Thanks for sharing this mod - fits what i was looking for perfectly.


All times are GMT -8. The time now is 07:28 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.