News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Some general questions about rating

Started by Ducksoul, December 20, 2011, 18:05:04 PM

Previous topic - Next topic

Ducksoul

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

Ducksoul

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; ?>

PRO

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  //

Ducksoul

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]

PRO

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.


Ducksoul

Unfortunately this doesn't save the problem. "$this->rating" doesn't exist which means that in category view all products are regarded as unrated.

PRO

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

Ducksoul

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]

Ducksoul


vapro

In VM 2.0.2 same problem for me. Any other idea?

hollywooood

Joomla 2.5.4
Virtuemart 2.0.6
PHP 5.2.17
MySQL 5.5.21-55
APACHE 2.2.22