Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

reviews show in product but not in reviews section


Guest

Recommended Posts

The problem is that product_reviews_info.php, does the query before it includes the left column. Thus, the box squashes the info when it is in the left column (which is after the query but before the middle section of the page is rendered). Renaming all instances of $review ($review_box or $review_info) in either includes/boxes/reviews.php or product_reviews_info.php would probably fix it. You could also move the query after the include of the left column; that would probably work too.

 

Hth,

Matt

Link to comment
Share on other sites

Hi,

 

I replaced $review with $review_box...there were 30 of them in product_reviews_info.php and it started working.

 

Then, I put the product_reviews_info.php back to $review and changed only the includes/boxes/reviews.php because there were only 6 of those and it is working.

 

Could you please elaborate on why I renamed $review to $review_box in includes/boxes/reviews.php?

 

Also, for future reference could you give me the exact code of the reviews query that would go after the left column? I think you are talking about the code in the header of product_reviews_info.php but don't know which lines.

 

Thanks!

 

I have to change several sites.

 

Is there one way that is better than another way?

Link to comment
Share on other sites

Lines 28-41 would move:

  $review_query = tep_db_query("select rd.reviews_text, r.reviews_rating, r.reviews_id, r.customers_name, r.date_added, r.reviews_read, p.products_id, p.products_price, p.products_tax_class_id, p.products_image, p.products_model, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where r.reviews_id = '" . (int)$HTTP_GET_VARS['reviews_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and r.products_id = p.products_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '". (int)$languages_id . "'");
 $review = tep_db_fetch_array($review_query);

 if ($new_price = tep_get_products_special_price($review['products_id'])) {
   $products_price = '<s>' . $currencies->display_price($review['products_price'], tep_get_tax_rate($review['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($review['products_tax_class_id'])) . '</span>';
 } else {
   $products_price = $currencies->display_price($review['products_price'], tep_get_tax_rate($review['products_tax_class_id']));
 }

 if (tep_not_null($review['products_model'])) {
   $products_name = $review['products_name'] . '<br><span class="smallText">[' . $review['products_model'] . ']</span>';
 } else {
   $products_name = $review['products_name'];
 }

They would have to go right after the left column was included, because the center content needs them.

 

Hth,

Matt

Link to comment
Share on other sites

Notice that the second line of the previous post (I posted before I meant to do so) has $review= in it. It assigns it an array with various contents. Later, the reviews box (includes/boxes/reviews.php) also has $review= in it which assigns a different array (line 34) and then another which assigns it a string (line 36).

 

So around line 29 of product_reviews_info.php, it assigns $review. Around line 70 it includes the left column which includes the reviews box which assigns a string to $review. Around lines 93-4, it tries to use $review as an array. However, at this point $review is a string, so referencing it as an array has goofy results. Changing $review to $review_box in the box file leaves $review as the array which was originally set around line 29.

 

Hth,

Matt

Link to comment
Share on other sites

How funny ... that was my solution too :)

 

The same variable is used in the /boxes/reviews.php as in the

product_reviews_info.php so ... it gets overwritten when the page draws.

 

Open /includes/boxes/reviews.php and do a global replace on $review with

$review_box

 

This will change the variable to be unique. And now it will run properly in either

column.

Link to comment
Share on other sites

Does that qualify for a bug report? :lol:

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Make 2 files, oops.php:

<?php
$review = 'Two<br />';
echo $review;
?>

and example.php:

<?php
$review = array('1a<br />');
echo $review[0];
include('oops.php');
?>

This is the equivalent of the original situation with the base layout and outputs

1a

Two

Now, move the include in example.php like this:
<?php
$review = array('1a<br />');
include('oops.php');
echo $review[0];
?>

This is the equivalent of moving the box from the right to the left column. Now it outputs something like

Two

T

Now, what is happening? Well, when PHP sees the include, it pulls the code from that file into the including file, so the second version of example.php is the equivalent of
<?php
$review = array('1a<br />');
$review = 'Two<br />';
echo $review;
echo $review[0];
?>

Note that we assign to $review twice in a row, effectively making the first assignment meaningless. The first echo works fine. The second echo tries to get the 0th element of the array $review, but $review isn't an array anymore, it's a string. Thus, it outputs a single letter (I think it would be the first from the string for all string indexes like 'review_name', etc.). Changing to $review_box makes it look like

<?php
$review = array('1a<br />');
$review_box = 'Two<br />';
echo $review_box;
echo $review[0];
?>

which works because the second assignment is to a different variable than the first. This preserves the contents of the first variable.

 

If it's a bug (as opposed to a feature that has undesired side effects in this case), then I would argue that the correct solution is to move the review query after the column left include. That would avoid the problem of the box code stepping on the results of the query. The query would now be run *after* the box code and would no longer be affected by the contents of column_left.

 

It could also reasonably be argued that all box variables should include a prefix or suffix to designate that they are for use in boxes (essentially what we are doing by switching $review to $review_box). This could also be fixed by changing the columns or the boxes to function calls. Then they would use separate name spaces from the content page and thus avoid interfering with it.

 

Hth,

Matt

Link to comment
Share on other sites

How funny ... that was my solution too :)

 

The same variable is used in the /boxes/reviews.php as in the

product_reviews_info.php so ... it gets overwritten when the page draws.

 

Open /includes/boxes/reviews.php and do a global replace on $review with

$review_box

 

This will change the variable to be unique. And now it will run properly in either

column.

Thanks all!!!

this was a easy fix...

<span style='font-family:Courier'>If you can't fix it Perl it!!!...</span>

******************************

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...