- Posts: 7
COMMUNITY FORUM
How to show item ratings in the K2 Content Module?
- arien101
-
Topic Author
- Offline
- New Member
Less
More
13 years 5 months ago #60143
by arien101
How to show item ratings in the K2 Content Module? was created by arien101
Hi,
I use a K2 Content Module to display a list of items sorted by their rating on the homepage. So far so good.
Now I would like to display the current rating next to each item in the list.
I have figured out that the .php file I need to edit is default.php in the mod_k2_module directory. I have copied over the itemRating code from category_item.php, but that only shows grey stars and not the item rating.
I figure this might be becauseonly works on the page of the item. Unfortunately I lack the PHP skills to figure out how to change this.
Any idea what code I would need?
Thanks!
I use a K2 Content Module to display a list of items sorted by their rating on the homepage. So far so good.
Now I would like to display the current rating next to each item in the list.
I have figured out that the .php file I need to edit is default.php in the mod_k2_module directory. I have copied over the itemRating code from category_item.php, but that only shows grey stars and not the item rating.
I figure this might be because
<?php echo $this->item->id; ?>
Any idea what code I would need?
Thanks!
Please Log in or Create an account to join the conversation.
- DJ Enterprises
-
- Offline
- New Member
Less
More
- Posts: 13
13 years 5 months ago #60144
by DJ Enterprises
Replied by DJ Enterprises on topic Re: How to show item ratings in the K2 Content Module?
Anyone?
I would like to know about the Ratings as well
Seems as if it was overlooked in development
Thank you for your time
I would like to know about the Ratings as well
Seems as if it was overlooked in development
Thank you for your time
Please Log in or Create an account to join the conversation.
- Kit
-
- Offline
- Junior Member
Less
More
- Posts: 38
13 years 2 weeks ago #60145
by Kit
Replied by Kit on topic Re: How to show item ratings in the K2 Content Module?
I, too, would like to know how to do this.
Anyone have an answer?
Thanks in advance...
Anyone have an answer?
Thanks in advance...
Please Log in or Create an account to join the conversation.
- Andrey Miasoedov
-
- Offline
- Senior Member
13 years 2 weeks ago #60146
by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: How to show item ratings in the K2 Content Module?
Hello, all.
You need to do the following, for showing item rating in mod_k2_content:
1) In helper.php before $rows[] = $item; at line 569 add the following:
$item->votingPercentage = $model->getVotesPercentage($item->id);
$item->numOfvotes = $model->getVotesNum($item->id);
2) Copy rating block from item.php template (or category_item.php) to any place in default.php of mod_k2_content;
3) Change all "$this->item" to "$item" in rating block text.
You need to do the following, for showing item rating in mod_k2_content:
1) In helper.php before $rows[] = $item; at line 569 add the following:
$item->votingPercentage = $model->getVotesPercentage($item->id);
$item->numOfvotes = $model->getVotesNum($item->id);
2) Copy rating block from item.php template (or category_item.php) to any place in default.php of mod_k2_content;
3) Change all "$this->item" to "$item" in rating block text.
Please Log in or Create an account to join the conversation.
- Kit
-
- Offline
- Junior Member
Less
More
- Posts: 38
13 years 2 weeks ago - 13 years 2 weeks ago #60147
by Kit
Replied by Kit on topic Re: How to show item ratings in the K2 Content Module?
Andrey, you ROCK!! :woohoo:
That got me EXACTLY where I needed to be.
Small fyis to anyone else who happens to come along after this with the same issue, if they need it:
1. the helper.php is at: modules -> mod_k2_content -> helper.php
2. the item.php template (or category_item.php) are in: components -> com_k2 -> templates -> default -> item.php template (or category_item.php)
3. don't copy the php code on top or bottom of the <!-- Item Rating --> section
4. If you leave the code as it is, people will still be able to vote. To JUST show the star rating and NOT have people vote, take out:
replace this:
That got me EXACTLY where I needed to be.
Small fyis to anyone else who happens to come along after this with the same issue, if they need it:
1. the helper.php is at: modules -> mod_k2_content -> helper.php
2. the item.php template (or category_item.php) are in: components -> com_k2 -> templates -> default -> item.php template (or category_item.php)
3. don't copy the php code on top or bottom of the <!-- Item Rating --> section
4. If you leave the code as it is, people will still be able to vote. To JUST show the star rating and NOT have people vote, take out:
replace this:
Please Log in or Create an account to join the conversation.
- Adam
-
- Offline
- New Member
Less
More
- Posts: 1
12 years 4 months ago #60148
by Adam
Replied by Adam on topic Re: How to show item ratings in the K2 Content Module?
Hi
I have one more question. Is it possible to get a result like on the image "siteissue.jpg " without clicking the mouse on the stars?
I have one more question. Is it possible to get a result like on the image "siteissue.jpg " without clicking the mouse on the stars?
Please Log in or Create an account to join the conversation.
- jeyjoo
-
- Offline
- New Member
Less
More
- Posts: 18
12 years 1 day ago #60149
by jeyjoo
Replied by jeyjoo on topic Re: How to show item ratings in the K2 Content Module?
Nice - thanks Andrey
Please Log in or Create an account to join the conversation.
- Jr Tony Gvr
-
- Offline
- New Member
Less
More
- Posts: 2
11 years 11 months ago #60150
by Jr Tony Gvr
Replied by Jr Tony Gvr on topic Re: How to show item ratings in the K2 Content Module?
i have a problem here :( star show in last item :( not look like the demo you do , what should i do now :(here is my code in default.php
hope to see your answer soon
<div class="catItemRatingBlock">
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $item->id; ?>" style="width:<?php echo $item->votingPercentage; ?>%;"></li>
</ul>
<div id="itemRatingLog<?php echo $item->id; ?>" class="itemRatingLog"><?php echo $item->numOfvotes; ?></div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
hope to see your answer soon
Please Log in or Create an account to join the conversation.
- Jr Tony Gvr
-
- Offline
- New Member
Less
More
- Posts: 2
11 years 11 months ago #60151
by Jr Tony Gvr
Replied by Jr Tony Gvr on topic Re: How to show item ratings in the K2 Content Module?
Small tip to anyone else who happens to come along after this with the same issue, and you don't know all of solution of andrey and kit explain .......
you copy the code like previous comment of me and copy in module/mod_k2_content/tmpl/default/default.php in line 39 you will see, paste my code in previous comment after this line , and check the result , if you want display a star in another position , u can paste in every you want in default template of module k2 content
you copy the code like previous comment of me and copy in module/mod_k2_content/tmpl/default/default.php in line 39 you will see
<?php if($params->get('itemTitle')): ?>
<a class="moduleItemTitle" href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- Alessandro
-
- Offline
- New Member
Less
More
- Posts: 1
11 years 7 months ago #60152
by Alessandro
Replied by Alessandro on topic Re: How to show item ratings in the K2 Content Module?
Hello!
To show rating stars in News Show Pro GK5 use these variables:
:)
To show rating stars in News Show Pro GK5 use these variables:
<li class="itemCurrentRating" id="itemCurrentRating" style="width:'. number_format(($item['rating_sum'] / $item['rating_count'])/5*100,0) . '%;"></li>
:)
Please Log in or Create an account to join the conversation.