Zen Cart Logo
Forums / All Other Contributions/Addons / A simple bit of code to move...keeps crashing! average product rating

A simple bit of code to move...keeps crashing! average product rating

Locked

Views: 1,671

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
19 Feb 2010, 12:36 PM
#1
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

A simple bit of code to move...keeps crashing! average product rating

Hi,

I am looking to move a bit of code but, no matter what I try it keeps crashing the product info page. If you look at my site i'll try and explain what I'm trying to do:

At the bottom of the page I want the reviews button to be underneath the stars rating. This is the code:

<!--bof Reviews button and count--> <?php if ($flag_show_product_info_reviews == 1) { // if more than 0 reviews, then show reviews button; otherwise, show the "write review" button if ($reviews->fields['count'] > 0 ) { ?> <div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div> <br class="clearBoth" /> <?php // 2P modified BOF - Average Product Rating echo '<p class="reviewCount">'; if ($flag_show_product_info_reviews_count == 1) { echo TEXT_CURRENT_REVIEWS . ' <strong>' . $reviews->fields['count'] . '</strong><br />'; $stars_image_suffix = str_replace('.', '_', zen_round($reviews_average_rating->fields['average_rating'] * 2, 0) / 2); // for stars_0_5.gif, stars_1.gif, stars_1_5.gif etc. $average_rating = zen_round($reviews_average_rating->fields['average_rating'], 2); echo TEXT_CURRENT_REVIEWS_RATING . ' <strong>' . $average_rating . '</strong> ' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $stars_image_suffix . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $average_rating)); } else { echo ''; } echo '</p>'; // 2P modified EOF - Average Product Rating ?> <?php } else { ?> <div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div> <br class="clearBoth" /> <?php } } ?> <!--eof Reviews button and count -->

I've tried moving some code around but nothing seems to work. It seems simple so does anybody have any ideas? Please!!!

Gary :smile:

19 Feb 2010, 12:39 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: A simple bit of code to move...keeps crashing! average product rating

What you posted is not the original code???

Use the code tags #

Zen-Venom Get Bitten

19 Feb 2010, 12:43 PM
#3
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: A simple bit of code to move...keeps crashing! average product rating

kobra:

What you posted is not the original code???

Use the code tags #

Hi,

Sorry, I didn't know about the code tags.

No, it's a code from a mod but, even so, surely there must be a way of moving it around to get it to work?

Gary

19 Feb 2010, 12:48 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: A simple bit of code to move...keeps crashing! average product rating

What mod?

Can you start with the default file?

The items are fairly well seperated with comments of BOF & EOF and one can move complete blocks without unnecessary strain

Zen-Venom Get Bitten

19 Feb 2010, 1:23 PM
#5
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: A simple bit of code to move...keeps crashing! average product rating

kobra:

What mod?

Can you start with the default file?

The items are fairly well seperated with comments of BOF & EOF and one can move complete blocks without unnecessary strain

The mod is 'average product rating'.

I'm sure it's something to do with moving this bit of the code to the bottom:

<?php
if ($flag_show_product_info_reviews == 1) {
// if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
if ($reviews->fields['count'] > 0 ) { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div>

However, when I move it the product listings page doesn't work.

Gary :smile:

19 Feb 2010, 4:04 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: A simple bit of code to move...keeps crashing! average product rating

Would have to see more of the code

I willl look for the mod when I make time

Zen-Venom Get Bitten

19 Feb 2010, 5:50 PM
#7
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: A simple bit of code to move...keeps crashing! average product rating

kobra:

Would have to see more of the code

I willl look for the mod when I make time

Thanks Kobra. I really appreciate you taking the time. :D

The mod is here if that helps. :smile:

20 Feb 2010, 8:27 AM
#8
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: A simple bit of code to move...keeps crashing! average product rating

Looked at this and I thought that the alignment was as it should be

Moved it as I believe you want and it is not aligned in an attractive manner IMO
BUT look at this code and compare to the mods original

<!--eof Tell a Friend button -->
<?php // 2P modified BOF - Average Product Rating
  echo '<p class="reviewCount">';
  if ($flag_show_product_info_reviews_count == 1) {
    echo TEXT_CURRENT_REVIEWS . ' <strong>' . $reviews->fields['count'] . '</strong><br />';
    $stars_image_suffix = str_replace('.', '_', zen_round($reviews_average_rating->fields['average_rating'] * 2, 0) / 2); // for stars_0_5.gif, stars_1.gif, stars_1_5.gif etc.
    $average_rating = zen_round($reviews_average_rating->fields['average_rating'], 2);
    echo TEXT_CURRENT_REVIEWS_RATING . ' <strong>' . $average_rating . '</strong> ' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $stars_image_suffix . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $average_rating));
  } else {
    echo '';
  }
  echo '</p>';
// 2P modified EOF - Average Product Rating ?>
<!--bof Reviews button and count-->
<?php
  if ($flag_show_product_info_reviews == 1) {
    // if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
    if ($reviews->fields['count'] > 0 ) { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div>
<br class="clearBoth" />

<?php } else { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<?php
  }
}
?>
<!--eof Reviews button and count -->

Zen-Venom Get Bitten

9 Mar 2010, 7:53 AM
#9
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: A simple bit of code to move...keeps crashing! average product rating

Hi Kobra,

Sorry for the delay in saying thank you. I gave up on coding this in the end and have got someone else to do it for me.

Thanks for you helps though.

Gary :smile: