VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Ducksoul on December 20, 2011, 18:05:04 PM

Title: Some general questions about rating
Post by: Ducksoul on December 20, 2011, 18:05:04 PM
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
Title: Re: Some general questions about rating
Post by: Ducksoul on December 23, 2011, 21:02:52 PM
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; ?>
Title: Re: Some general questions about rating
Post by: PRO on December 23, 2011, 21:43:35 PM
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  //
Title: Re: Some general questions about rating
Post by: Ducksoul on December 23, 2011, 22:52:18 PM
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]
Title: Re: Some general questions about rating
Post by: PRO on December 24, 2011, 00:27:42 AM
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.

Title: Re: Some general questions about rating
Post by: Ducksoul on December 24, 2011, 01:21:59 AM
Unfortunately this doesn't save the problem. "$this->rating" doesn't exist which means that in category view all products are regarded as unrated.
Title: Re: Some general questions about rating
Post by: PRO on December 24, 2011, 01:32:05 AM
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
Title: Re: Some general questions about rating
Post by: Ducksoul on December 24, 2011, 02:23:34 AM
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]
Title: Re: Some general questions about rating
Post by: Ducksoul on December 29, 2011, 20:06:30 PM
Does nobody have a clue? :(
Title: Re: Some general questions about rating
Post by: vapro on February 25, 2012, 05:40:51 AM
In VM 2.0.2 same problem for me. Any other idea?
Title: Re: Some general questions about rating
Post by: hollywooood on February 25, 2012, 10:14:50 AM
This might help you out here:

http://forum.virtuemart.net/index.php?topic=97611.0