Keyword

[SOLVED] Item rating on Generic page

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #144985 by Krikor Boghossian
Item rating on Generic page was created by Krikor Boghossian
Hello,

This will produce non valid HTML.
You need to replace the li tags with a div one.

Then send me a link so I can take a look, since this a visual issue.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #144992 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
It seems to work fine now on my end.
It was probably a CSS thing, right?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #145012 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
The rating is not included in the generic view.
You can 'hack' a core file in order to include it but this is not recommended.

Backup before editing the /components/com_k2/models/item.php

Line 194 locate
if (($view == 'item' && $item->params->get('itemRating')) || ($view == 'itemlist' && ($task == '' || $task == 'category' ) && $item->params->get('catItemRating')))

and add || $task == 'search'
if (($view == 'item' && $item->params->get('itemRating')) ||  $task == 'search' || ($view == 'itemlist' && ($task == '' || $task == 'category' ) && $item->params->get('catItemRating')))

Finally you should also remove
<?php if($item->params->get('catItemRating')): ?>
and the appropriate <?php endif; ?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #145030 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
Because you will lose your edits when you update and you will have to reapply them.
In general editing core files is not recommended since they might lead into unexpected results. This is a minor edit however.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #145120 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
The template files can be overriden so you can freely change every aspect of them.

Just in case if you don't use overrides this is a good starting point: getk2.org/documentation/tutorials/174

Kudos on the changelog :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 10 months ago #145135 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
You 're welcome :)
Since you know your way around coding why not give bitbucket.org/ for hosting code a try?

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

More
9 years 9 months ago - 9 years 9 months ago #145843 by razen
Replied by razen on topic Item rating on Generic page
I hope you wont blame me for grave-digging since I got exactly the same problem but can't fix it with this advice.

My actual code in a custom template is this:
<!-- RATING START -->
		<div class="itemRatingForm">
			<ul class="itemRatingList">
				<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_5_STARS_OUT_OF_5'); ?>" class="five-stars">5</a></li>
			</ul>
			<div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog"><?php echo $this->item->numOfvotes; ?></div>
		</div>
	<!-- RATING END -->

Those are my edits to the item.php in the models-folder:
if (($view == 'item' && $item->params->get('itemRating')) ||  $task == 'search' || ($view == 'itemlist' && ($task == '' || $task == 'category' ) && $item->params->get('catItemRating')))
		{
			$item->votingPercentage = $this->getVotesPercentage($item->id);
			$item->numOfvotes = $this->getVotesNum($item->id);

		}

But the result: Empty 5 stars and the vote don't work.

Here's the link: minecraft-heads.com/heads/itemlist/search?searchword=Phoenix&categories=

Same problem with the tag-page where I tried the same: minecraft-heads.com/bird

Thanks for the help :)
Last edit: 9 years 9 months ago by razen.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 9 months ago #145892 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
Hello,

Instead of $this->item->id you should use $item->id.
Also for the tag you should add $task == 'tag' to the model.

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

More
9 years 9 months ago #145914 by razen
Replied by razen on topic Item rating on Generic page
worked at tag-page and search-page, thanks! :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar Topic Author
  • Offline
  • Platinum Member
More
9 years 9 months ago #145923 by Krikor Boghossian
Replied by Krikor Boghossian on topic Item rating on Generic page
You 're welcome Razen :)

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


Powered by Kunena Forum