Author Topic: Rating Images not showing up  (Read 31329 times)

tobisagt

  • Jr. Member
  • **
  • Posts: 104
Re: Rating Images not showing up
« Reply #15 on: February 25, 2012, 18:32:04 pm »
thx hollywood,

i modified your code a bit. I think this makes more sense!

Code: [Select]
if ($this->rating->rating < "0.25"){
echo '<div class="rating "zero"></div>';
}

if ($this->rating->rating >= "0.25" & $this->rating->rating < "0.75"){
echo '<div class="rating zerofive"></div>';
}

if ($this->rating->rating >= "0.75" & $this->rating->rating < "1.25"){
echo '<div class="rating one"></div>';
}

if ($this->rating->rating >= "1.25" & $this->rating->rating < "1.75"){
echo '<div class="rating onefive"></div>';
}

if ($this->rating->rating >= "1.75" & $this->rating->rating < "2.25"){
echo '<div class="rating two"></div>';
}

if ($this->rating->rating >= "2.25" & $this->rating->rating < "2.75"){
echo '<div class="rating twofive"></div>';
}

if ($this->rating->rating >= "2.75" & $this->rating->rating < "3.25"){
echo '<div class="rating three"></div>';
}

if ($this->rating->rating >= "3.25" & $this->rating->rating < "3.75"){
echo '<div class="rating threefive"></div>';
}

if ($this->rating->rating >= "3.75" & $this->rating->rating < "4.25"){
echo '<div class="rating four"></div>';
}

if ($this->rating->rating >= "4.25" & $this->rating->rating < "4.75"){
echo '<div class="rating fourfive"></div>';
}

if ($this->rating->rating >= "4.75" & $this->rating->rating <= "5"){
echo '<div class="rating five"></div>';
}

I've made my own stars images which shows half stars also.
Your solution works only if there a "full number" vote, if you know what i mean. If there is a 2 stars and 3 stars vote, it should show 2,5 stars.

I uploaded my stars jpg too, if someone want to use it.


EDIT: I updated to Joomla 2.5 and VM 2.0.2. All works fine now!

[attachment cleanup by admin]

vapro

  • Beginner
  • *
  • Posts: 9
Re: Rating Images not showing up
« Reply #16 on: February 26, 2012, 02:09:20 am »
Problem solved.

it was a big bug...


this lines missing from components>com_virtuemart>views>category>view.html.php file:

find:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

replace:
Code: [Select]
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);

// added lines from  components>com_virtuemart>views>productdetails>view.html.php
$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
$this->assignRef('rating', $rating);

Add this lines where you want to diplay stars: components>com_virtuemart>views>category>tmpl>default.php

Code: [Select]
<!-- The "Average Customer Rating" Part by Vapro -->
<?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) . '/'$maxrating;
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;
?>

                    <span class="vote">
<?php echo $rating  ?>
                    <br/>
                        <span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
                            <span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
                            </span>
                        </span>
</span>
<?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;

}?>

hollywooood

  • Jr. Member
  • **
  • Posts: 51
  • If everything was easy it woud be frickin awesome!
Re: Rating Images not showing up
« Reply #17 on: February 26, 2012, 07:54:33 am »
Hi Electricity...

Couldn't you add the extra if statements for the extra ratings or change it as you need?  Maybe I am unclear on what you are suggesting.

Glad I could at least get the ball rolling on this problem.  Nice work vapro...

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

sandstorm

  • Jr. Member
  • **
  • Posts: 234
    • ConCom
  • Skype Name: sandstorm871
  • VirtueMart Version: 3.0.16
Re: Rating Images not showing up
« Reply #18 on: February 29, 2012, 17:03:28 pm »
Ive now upgraded to J2.5.1, VM 2.02 and still this problem persists. I have tried with default templates, both Joomla and virtuemart.

Can anyone on the VM dev team comment if this is a bug or not?

I will look at Vapro's fix, but worried that this will be overwritten when another upgrade comes out ?

Andy
J3.6.4 / PHP7.0.12
VM3.0.16

sandstorm

  • Jr. Member
  • **
  • Posts: 234
    • ConCom
  • Skype Name: sandstorm871
  • VirtueMart Version: 3.0.16
Re: Rating Images not showing up
« Reply #19 on: February 29, 2012, 17:13:13 pm »
I only just notice after reading VAPRO's comments.
I cant get my ratings to show in details page.

The modified code in VAPRO's post is for category view
J3.6.4 / PHP7.0.12
VM3.0.16

sandstorm

  • Jr. Member
  • **
  • Posts: 234
    • ConCom
  • Skype Name: sandstorm871
  • VirtueMart Version: 3.0.16
Re: Rating Images not showing up
« Reply #20 on: March 21, 2012, 10:49:37 am »
problem persists? 
Anybody else see this in there sites? or have any advice for me
J3.6.4 / PHP7.0.12
VM3.0.16

hollywooood

  • Jr. Member
  • **
  • Posts: 51
  • If everything was easy it woud be frickin awesome!
Re: Rating Images not showing up
« Reply #21 on: March 28, 2012, 07:48:51 am »
Hey tobisagt, what does your css look like for this?  I just migrated to 2.5 and 2.0.2 and need to add this in...

thanks for any help on that...
Joomla 2.5.4
Virtuemart 2.0.6
PHP 5.2.17
MySQL 5.5.21-55
APACHE 2.2.22

fexnok

  • Beginner
  • *
  • Posts: 15
Re: Rating Images not showing up
« Reply #22 on: April 01, 2012, 15:40:35 pm »
Where can I find those images? I have just downloaded virtuemart 2.0.2 and I couldn't find them.

Thanks

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27387
  • Always on vacation
    • Jenkin Hill Internet
Re: Rating Images not showing up
« Reply #23 on: April 01, 2012, 16:10:30 pm »
The image is in joomla_root/components/com_virtuemart/assets/images/color-stars.png

Display of the review rating image is dependant on the Joomla template and that templates's css. The attached is the display in one of the Linelab templates.

[attachment cleanup by admin]
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.10057 on Joomla 3.9.6 PHP 7.0.33
Testing VM 3.4.5.10059 on Joomla 3.9.6

hollywooood

  • Jr. Member
  • **
  • Posts: 51
  • If everything was easy it woud be frickin awesome!
Re: Rating Images not showing up
« Reply #24 on: April 03, 2012, 08:36:17 am »
Somethings are waay more easier than we make them out to be...

For those who don't know on this and are making a custom template here is what you may need to do if you are using your own css.

Make sure you copy & paste these lines in your style sheet from virtuemart-ltr.css:
Code: [Select]
.ratingbox {
position:relative;
display:block;
width:120px;
height:24px;
background:url("pathto/images/color-stars.png") repeat-x scroll 0 bottom transparent;
}
.ratingbox span {
background:url(pathto/images/color-stars.png) repeat-x;
display:block;
width:1%;
height:24px;
position:absolute;
}
.stars-orange{background-position:0 0 !important;}
.stars-red{background-position:0 -54px !important;}
.stars-green{background-position:0 -108px !important; }
.stars-blue{background-position:0 -162px !important;}
.stars-purple{background-position:0 -216px !important;}

You will need this somewhere in your productdetails default.php page:

Code: [Select]
<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>
<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="vmicon ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}
?>

You'll notice that it not only takes care of the rated image, it will also handle the JS review and ratings display..

it really is that easy...the main thing was that I missed the css for this and that is what really gave me a headache...I was overthinking it way too much.
Joomla 2.5.4
Virtuemart 2.0.6
PHP 5.2.17
MySQL 5.5.21-55
APACHE 2.2.22

DaggaTora

  • Jr. Member
  • **
  • Posts: 253
Re: Rating Images not showing up
« Reply #25 on: June 19, 2012, 18:56:58 pm »
This is great guys but... what about to hide rating if the product has not been review?
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

DaggaTora

  • Jr. Member
  • **
  • Posts: 253
Re: Rating Images not showing up
« Reply #26 on: June 19, 2012, 19:05:22 pm »
I just delete <span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED') ?> hope it works!  ;D
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

Sonictech

  • Beginner
  • *
  • Posts: 31
Re: Rating Images not showing up
« Reply #27 on: June 21, 2012, 04:49:06 am »
I just delete <span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED') ?> hope it works!  ;D

Where you able to solve this, did this work by deleting  line you listed above?  I have followed the instructions so far and I see the ratings in the category area but the only issue it shows the same rating on all products even if they have not been rated yet.  I tried removing the line above but it did not work, any other idea?

Thanks for any help! 8)

DaggaTora

  • Jr. Member
  • **
  • Posts: 253
Re: Rating Images not showing up
« Reply #28 on: June 21, 2012, 09:30:30 am »
This is what i did to have stars when someone voted and to shows nothing when nobody has vote:

Code: [Select]
<?php
if ($this->showRating) {
    $maxrating VmConfig::get('vm_maximum_rating_scale',5);

if (empty($this->rating)) { ?>

<span class="vote" style="display:none"><?php echo JText::_('COM_VIRTUEMART_RATING').' '.JText::_('COM_VIRTUEMART_UNRATED'?></span>

<?php } else {
$ratingwidth = ( $this->rating->rating 100 ) / $maxrating;//I don't use round as percetntage with works perfect, as for me
?>

<span class="vote">
<!--<?php echo JText::_('COM_VIRTUEMART_RATING').' '.round($this->rating->rating2) . '/'$maxrating?><br/>-->
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . $this->rating->rating '/' $maxrating?>" class="ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth;?>%">
</span>
</span>
</span>
<?php
}
}
?>

Hope it helps!
Joomla 2.5.17 | VM2.0.26d | PHP 5.3.28

Sonictech

  • Beginner
  • *
  • Posts: 31
Re: Rating Images not showing up
« Reply #29 on: June 22, 2012, 04:48:28 am »
I put the code in the category/default.php and have added a couple of stars to a product, no luck.  I then put back the original code and I see the stars but none of them are gold color, any idea?

Thanks,
Shawn