Hey,
I'm busy editing the template of my product browse page.. Here I found the following lines of code:
<!-- The "Average Customer Rating" Part -->
<?php if (VmConfig::get('pshop_allow_reviews') == 1) { ?>
<span class="contentpagetitle"><?php echo JText::_('COM_VIRTUEMART_CUSTOMER_RATING') ?>:</span>
<br />
<?php
// $img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
// echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
// echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes; ?>
<?php } ?>
I really want to show the rating but it won't show up. I have enabled rating and reviews in configuration --> shopfront.. If I remove the if-clause it works fine.. Did I miss a setting? And where will the user be able to write reviews and rate the product?
Thanks a lot
I realized that I posted this thread in the wrong topic, but I don't want to start a new thread now.
My problem:
The following code doesn't work, cause "$product->votes->rating" and "$product->votes->allvotes" don't return any value. Why is that?
$img_url = JURI::root().VmConfig::get('assets_general_path').'/reviews/'.$product->votes->rating.'.gif';
echo JHTML::image($img_url, $product->votes->rating.' '.JText::_('COM_VIRTUEMART_REVIEW_STARS'));
echo JText::_('COM_VIRTUEMART_TOTAL_VOTES').": ". $product->votes->allvotes; ?>
did you remove these //
That are in front of the code? Look at your first code post. Its yellow because its got these in front //
Haha, yeah of course I removed the slashes. That's why I reposted the code in my previous post so that people can see that they are gone :-p
I attached a screenshot of the view as it is right now. As you can see the php-code get's interpreted. It looks like "$product->votes->rating" and "$product->votes->allvotes" don't return any values or just blank values. :-/
[attachment cleanup by admin]
In the product details page the code is quite different.
<?php
if($this->showRating){
$maxrating = VmConfig::get('vm_maximum_rating_scale',5);
$rating = empty($this->rating)? JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'):JText::_('COM_VIRTUEMART_RATING') . round($this->rating->rating, 2) . '/'. $maxrating;
echo $rating;
}
Then it calls the stars with css
<span class="vmicon vm2-stars'.$num.'" title="'.$title.'"></span>
I dont think that code in the category page is up to date. It wasnt enabled, so seems like there was just larger things to take care of first.
Unfortunately this doesn't save the problem. "$this->rating" doesn't exist which means that in category view all products are regarded as unrated.
try it without $this
$product->rating
$this on the category page will be talking about the current category.
$this on the product page will be referring to the current product
I already tried that stuff.
Attached are to textfiles I generated using the print_r($product) in category view, respectively print_r($this) in detail view. You will see that in category view there are no variables that have any references to rating. It's the same for $this in category view. :(
[attachment cleanup by admin]
Does nobody have a clue? :(
In VM 2.0.2 same problem for me. Any other idea?
This might help you out here:
http://forum.virtuemart.net/index.php?topic=97611.0