Voting stars and empty rating - My suggestion

  • Posts: 382
  • Thank you received: 77
6 years 7 months ago #290208

-- HikaShop version -- : 3.4.0

Hi, Hikashop Team!

After updating to 3.4.0 the gray stars don't showing to guests if the rating is empty.
For someone it's good, for others it's bad.

I suggest to change a small piece of code in vote template mini.php

if(!$canVote && $row->hikashop_vote_total_vote == '0'){
	echo '<div class="hikashop_vote_stars">'.JText::_('HIKA_NO_VOTE').'</div>';
	return;
}

To:
if(!$canVote && $row->hikashop_vote_total_vote == '0'){
	echo '<div class="hk-rating hk-rating-empty" data-original-title="'.JText::_('HIKA_NO_VOTE').'" data-toggle="hk-tooltip">';
	for($i = 1; $i <= $row->hikashop_vote_nb_star; $i++) {
		echo '<span class="hk-rate-star state-empty"></span>';
	}
	echo '</div>';
	return;
}

This will enable us to control the display of the empty rating via CSS styles, without creating an override for this view.
.hk-rating.hk-rating-empty {
    display: none;
}

Perhaps you can include it in the next release.

Thank you
Best regards

The following user(s) said Thank You: Pierreco

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 7 months ago #290237

Hi,

Thank you for your feedback. That's a good idea.
However, we'll implement it like that:

if(!$canVote && $row->hikashop_vote_total_vote == '0'){
?>
<div class="hikashop_vote_stars">
	<div class="hk-rating-empty-label">
		<?php echo JText::_('HIKA_NO_VOTE'); ?>
	</div>
	<div class="hk-rating hk-rating-empty" data-original-title="<?php echo JText::_('HIKA_NO_VOTE'); ?>" data-toggle="hk-tooltip">
<?php
	for($i = 1; $i <= $row->hikashop_vote_nb_star; $i++) {
		echo '<span class="hk-rate-star state-empty"></span>';
	}
?>
	</div>;
</div>
<?php
	return;
}
So that people still have the "no votes" label by default and change change:
.hk-rating.hk-rating-empty {
display: none;
}
to:
.hk-rating-empty-label {
display: none;
}
to get the stars instead.

The following user(s) said Thank You: almika, Pierreco

Please Log in or Create an account to join the conversation.

  • Posts: 382
  • Thank you received: 77
6 years 7 months ago #290250

Hi, Nicolas!

Thank you for your answer.
Your code is more flexible than mine!

Best regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.040 seconds
Powered by Kunena Forum