Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Remove product reviews on main page only

Remove product reviews on main page only

Locked

Views: 3,974

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
17 Oct 2009, 2:12 AM
#1
robbinsgj avatar

robbinsgj

New Zenner

Join Date:
Jul 2009
Posts:
48
Plugin Contributions:
0

Remove product reviews on main page only

How could you remove the product review option on the right column but only on the main page.

I still want it to show on the product info page, just not on the main page. Turning off under admin shuts it completely off.

Ideas?

http://www.bloomfieldsportsshop.com/store

17 Oct 2009, 4:13 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

Using your templates and overrides, copy the:
/includes/modules/sideboxes/reviews.php

to your custom directory:
/includes/modules/sideboxes/your_template_dir/reviews.php

and change this line from:

if ($show_reviews == true) {

to read:

// do not show on home page
if ($this_is_home_page) {
  $show_reviews= false;
}

if ($show_reviews == true) {
17 Oct 2009, 4:18 AM
#3
robbinsgj avatar

robbinsgj

New Zenner

Join Date:
Jul 2009
Posts:
48
Plugin Contributions:
0

Re: Remove product reviews on main page only

Thanks Linda! Any idea on how to make the editable box show only on the front page and not on the product pages?

17 Oct 2009, 4:27 AM
#4
robbinsgj avatar

robbinsgj

New Zenner

Join Date:
Jul 2009
Posts:
48
Plugin Contributions:
0

Re: Remove product reviews on main page only

Ajeh:

Using your templates and overrides, copy the:
/includes/modules/sideboxes/reviews.php

to your custom directory:
/includes/modules/sideboxes/your_template_dir/reviews.php

and change this line from:

if ($show_reviews == true) {

> 
> to read:
> ```
// do not show on home page
if ($this_is_home_page) {
  $show_reviews= false;
}

if ($show_reviews == true) {

That line is not in /includes/modules/sideboxes/reviews.php

<?php
/**
 * reviews sidebox - displays a random product-review 
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license [url]http://www.zen-cart.com/license/2_0.txt[/url] GNU Public License V2.0
 * @version $Id: reviews.php 2718 2005-12-28 06:42:39Z drbyte $
 */

// if review must be approved or disabled do not show review
  $review_status = " and r.status = 1 ";

  $random_review_sidebox_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name
                    from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, "
                           . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                    where p.products_status = '1'
                    and p.products_id = r.products_id
                    and r.reviews_id = rd.reviews_id
                    and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'
                    and p.products_id = pd.products_id
                    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                    $review_status;

  if (isset($_GET['products_id'])) {
    $random_review_sidebox_select .= " and p.products_id = '" . (int)$_GET['products_id'] . "'";
  }
  $random_review_sidebox_select .= " limit " . MAX_RANDOM_SELECT_REVIEWS;
  $random_review_sidebox_product = zen_random_select($random_review_sidebox_select);
  if ($random_review_sidebox_product->RecordCount() > 0) {
// display random review box
    $review_box_text_query = "select substring(reviews_text, 1, 60) as reviews_text
                     from " . TABLE_REVIEWS_DESCRIPTION . "
                     where reviews_id = '" . (int)$random_review_sidebox_product->fields['reviews_id'] . "'
                     and languages_id = '" . (int)$_SESSION['languages_id'] . "'";

    $review_box_text = $db->Execute($review_box_text_query);

//    $review_box_text = zen_break_string(zen_output_string_protected($review_box_text->fields['reviews_text']), 15, '-<br />');
    $review_box_text = zen_break_string(nl2br(zen_output_string_protected(stripslashes($review_box_text->fields['reviews_text']))), 60, '-<br />');

    require($template->get_template_dir('tpl_reviews_random.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_random.php');
  } elseif (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
// display 'write a review' box
    require($template->get_template_dir('tpl_reviews_write.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_write.php');
  } else {
// display 'no reviews' box
    require($template->get_template_dir('tpl_reviews_none.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_none.php');
  }
  $title =  BOX_HEADING_REVIEWS;
  $title_link = FILENAME_REVIEWS;
  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
?>
17 Oct 2009, 2:50 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

Sorry ... I had a customized box ... use this for the file:

<?php
/**
 * reviews sidebox - displays a random product-review
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: reviews.php 2718 2005-12-28 06:42:39Z drbyte $
 */

// test if box should display
$show_reviews= true;

// do not show on home page
if ($this_is_home_page) {
  $show_reviews= false;
}

if ($show_reviews == true) {
// if review must be approved or disabled do not show review
  $review_status = " and r.status = 1 ";

  $random_review_sidebox_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name
                    from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, "
                           . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                    where p.products_status = '1'
                    and p.products_id = r.products_id
                    and r.reviews_id = rd.reviews_id
                    and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'
                    and p.products_id = pd.products_id
                    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                    $review_status;

  if (isset($_GET['products_id'])) {
    $random_review_sidebox_select .= " and p.products_id = '" . (int)$_GET['products_id'] . "'";
  }
  $random_review_sidebox_select .= " limit " . MAX_RANDOM_SELECT_REVIEWS;
  $random_review_sidebox_product = zen_random_select($random_review_sidebox_select);
  if ($random_review_sidebox_product->RecordCount() > 0) {
// display random review box
    $review_box_text_query = "select substring(reviews_text, 1, 60) as reviews_text
                     from " . TABLE_REVIEWS_DESCRIPTION . "
                     where reviews_id = '" . (int)$random_review_sidebox_product->fields['reviews_id'] . "'
                     and languages_id = '" . (int)$_SESSION['languages_id'] . "'";

    $review_box_text = $db->Execute($review_box_text_query);

//    $review_box_text = zen_break_string(zen_output_string_protected($review_box_text->fields['reviews_text']), 15, '-<br />');
    $review_box_text = zen_break_string(nl2br(zen_output_string_protected(stripslashes($review_box_text->fields['reviews_text']))), 60, '-<br />');

    require($template->get_template_dir('tpl_reviews_random.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_random.php');
  } elseif (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
// display 'write a review' box
    require($template->get_template_dir('tpl_reviews_write.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_write.php');
  } else {
// display 'no reviews' box
    require($template->get_template_dir('tpl_reviews_none.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_none.php');
  }
  $title =  BOX_HEADING_REVIEWS;
  $title_link = FILENAME_REVIEWS;
  require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

}
?>
17 Oct 2009, 3:29 PM
#6
robbinsgj avatar

robbinsgj

New Zenner

Join Date:
Jul 2009
Posts:
48
Plugin Contributions:
0

Re: Remove product reviews on main page only

Thanks again! I was struggling with this. :D

14 Jan 2010, 2:48 PM
#7
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Remove product reviews on main page only

Would it be possible to apply the above modified code to display the product reviews sidebox on JUST the Product Info page only?

14 Jan 2010, 4:39 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

In the IF statement you could use:
$_GET['main_page']

and when it is == to 'product_info' then it would allow the sidebox to display ...

14 Jan 2010, 7:14 PM
#9
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Remove product reviews on main page only

I tried the following but it removed the review sidebox completely :blush: :

<?php /** * reviews sidebox - displays a random product-review * * @package templateSystem * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: reviews.php 2718 2005-12-28 06:42:39Z drbyte $ */ // test if box should display $show_reviews= true; // do not show on home page if $_GET('main_page') { $show_reviews= false; } if ($show_reviews == true) { // if review must be approved or disabled do not show review $review_status = " and r.status = 1 "; $random_review_sidebox_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" . $review_status; if (isset($_GET['products_id'])) { $random_review_sidebox_select .= " and p.products_id = '" . (int)$_GET['products_id'] . "'"; } $random_review_sidebox_select .= " limit " . MAX_RANDOM_SELECT_REVIEWS; $random_review_sidebox_product = zen_random_select($random_review_sidebox_select); if ($random_review_sidebox_product->RecordCount() > 0) { // display random review box $review_box_text_query = "select substring(reviews_text, 1, 60) as reviews_text from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$random_review_sidebox_product->fields['reviews_id'] . "' and languages_id = '" . (int)$_SESSION['languages_id'] . "'"; $review_box_text = $db->Execute($review_box_text_query); // $review_box_text = zen_break_string(zen_output_string_protected($review_box_text->fields['reviews_text']), 15, '-<br />'); $review_box_text = zen_break_string(nl2br(zen_output_string_protected(stripslashes($review_box_text->fields['reviews_text']))), 60, '-<br />'); require($template->get_template_dir('tpl_reviews_random.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_random.php'); } elseif (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) { // display 'write a review' box require($template->get_template_dir('tpl_reviews_write.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_write.php'); } else { // display 'no reviews' box require($template->get_template_dir('tpl_reviews_none.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_reviews_none.php'); } $title = BOX_HEADING_REVIEWS; $title_link = FILENAME_REVIEWS; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); } ?>
14 Jan 2010, 8:37 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

Change your code:

// do not show on home page
if $_GET('main_page') {
$show_reviews= false;
}

to read:

// do not show on home page
if ($_GET('main_page') != 'product_info') {
  $show_reviews= false;
}

Note: if you use multiple product types, you may need to alter this code ...

15 Jan 2010, 12:28 AM
#11
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Remove product reviews on main page only

Couldn't get that to work :blush:
Seemed that the reviews sidebox was removed from all pages?

15 Jan 2010, 2:33 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

You are using:

// do not show on home page uses:
//if ($this_is_home_page) {

// only on product_info
if ($_GET['main_page'] != 'product_info') {
  $show_reviews= false;
}

NOTE: on the product_info you will see the Write a Review if there are not any reviews for the specific product and if there are reviews for the specific products then you will see a review, as that is how this sidebox works ...

15 Jan 2010, 1:07 PM
#13
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Remove product reviews on main page only

Ajeh:

You are using:

// do not show on home page uses:
//if ($this_is_home_page) {

// only on product_info
if ($_GET['main_page'] != 'product_info') {
$show_reviews= false;
}


Yep that did it, thanks (yet again!) Linda, your a star :smile:
15 Jan 2010, 8:09 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

Thanks for the update that this is now working for you ... that is always a help to others to know ... :smile:

5 Jun 2010, 3:20 AM
#15
ibifa avatar

ibifa

New Zenner

Join Date:
Feb 2010
Posts:
46
Plugin Contributions:
0

Re: Remove product reviews on main page only

I was looking to do the same thing: have the reviews appear only on the product pages, not the home page.

I plugged in the code as stated above (I did not copy the whole text, just the top section).

I have undone it now, but the end result is that my sideboxes below reviews are also not showing - on any page that the reviews box doesn't show.

Any ideas without me having to leave it on my site to show you?

I'm on 1.3.9c
sunflower_template

http:// garden offrancis. com

UPDATED: I have replaced the entire text you provided above - and it works great! My only concern is whether or not this affects the upgrade - have I undone anything that was modified by the upgrade? If so, what should I modify?

Thank you!

5 Jun 2010, 12:38 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Remove product reviews on main page only

Provided you are using the templates and overrides you should not be affecting any of the core code ...

21 Jun 2010, 5:39 AM
#17
andreitero avatar

andreitero

Zen Follower

Join Date:
Dec 2009
Posts:
207
Plugin Contributions:
0

Re: Remove product reviews on main page only

I am trying to display the banner_box sidebox only on about us page with this code:

if ($_GET['main_page'] != 'about_us') {
  $show_banner_box= false;
}

But it doesn't work. Anyone has any other suggestions?
Thanks!