Keyword

Changing the content rating from public to register

More
13 years 9 months ago #92425 by BN
Hello,

 

What the vote rating currently doing: It is available for ANYONE to rate 

 

The Problem: ANYONE can just vote without any reasons to back up the rating. This can be a problem if someone goes on a one star rating spree. 

 

What I want to do: I want only register users to be able to vote only if they leave a product comment. 

 

 

Does anyone know how I can go about doing this?

 

 

 

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

More
13 years 9 months ago #92426 by BN
can anyone help me with this?

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

More
13 years 9 months ago #92427 by william white
Replied by william white on topic Changing the content rating from public to register
You might try

{untested}

In item.php search for     <!-- Item Rating -->

Move the entire block of code including the line above     <!-- Item Rating -->

down to (search for  <!-- Item comments -->)

and wrap the entire block of code with something like

 $user =& JFactory::getUser();   if($user->get('guest') ==0 ):

with another  endif  at the bottom of the item comments block of code

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

More
13 years 9 months ago #92428 by Jiliko.net
William, you're almost right,

 


You have to change the test :

 


if($user->get('guest') ==0 ):

 

by

 


if( !($user->guest) ):

 

The 'guest' property returns true or false depending on user status. So here, if the user is not a guest, the code inside the if will be executed.

 

OlivierWilliam White said:

You might try

{untested}

In item.php search for     <!-- Item Rating -->

Move the entire block of code including the line above     <!-- Item Rating -->

down to (search for  <!-- Item comments -->)

and wrap the entire block of code with something like

 $user =& JFactory::getUser();   if($user->get('guest') ==0 ):

with another  endif  at the bottom of the item comments block of code

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

More
13 years 9 months ago #92429 by Terry Britton
Replied by Terry Britton on topic Changing the content rating from public to register
I would think it would be better to show ratings to both users and guests, but only let logged in users rate the article. I'm no javascript wiz, but here's what I came up with. In item.php and category_item.php add the following near the top (after the exec or die portion).

<?php$user = &JFactory::getUser();$userId = $user->get('id');if ($userId != 0) {     echo '<script type="text/javascript">var logged_in=true;</script>';} else {         echo '<script type="text/javascript">var logged_in=false;</script>';} ?>

 

This will test if the user is logged in and set a javascript variable. Then add the following to k2.js.

 

after line 52 add:

if (logged_in) {

after line 81 add:

}

 

This appears to work fine, guests will get a pointer when they hover over the stars, but nothing will happen if they click. If anyone knows how to keep the pointer from displaying, let me know.

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

More
13 years 9 months ago #92430 by BN
Thanks Terry! it worked! That was exactly what I was looking to do.


Terry A Britton said:

I would think it would be better to show ratings to both users and guests, but only let logged in users rate the article. I'm no javascript wiz, but here's what I came up with. In item.php and category_item.php add the following near the top (after the exec or die portion).

<?php$user = &JFactory::getUser();$userId = $user->get('id');if ($userId != 0) {     echo '<script type="text/javascript">var logged_in=true;</script>';} else {         echo '<script type="text/javascript">var logged_in=false;</script>';} ?>

 

This will test if the user is logged in and set a javascript variable. Then add the following to k2.js.

 

after line 52 add:

if (logged_in) {

after line 81 add:

}

 

This appears to work fine, guests will get a pointer when they hover over the stars, but nothing will happen if they click. If anyone knows how to keep the pointer from displaying, let me know.

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

More
13 years 8 months ago #92431 by Terry Britton
Replied by Terry Britton on topic Changing the content rating from public to register
I just noticed that my modificatin breaks the cancel button on the frontend edit page. I'll dig some more and post a solution if I find one.

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

More
13 years 8 months ago #92432 by Terry Britton
Replied by Terry Britton on topic Changing the content rating from public to register
I finally got back around to this issue. Add the following near the top of the item.php and category_item.php to determine if the user is logged in:

<?php$user = &JFactory::getUser();$userId = $user->get('id');?>

Add the if statement around the unnumbered list (approx. line 200 in item.php and 73 in category_item.php):

<ul class="itemRatingList">    <li class="itemCurrentRating" id="itemCurrentRating...    <?php if($userId != 0) : ?>        <li><a href="#" rel="<?php echo $this->item->id; ?>"...        <li><a href="#" rel="<?php echo $this->item->id; ?>"...        <li><a href="#" rel="<?php echo $this->item->id; ?>"...        <li><a href="#" rel="<?php echo $this->item->id; ?>"...        <li><a href="#" rel="<?php echo $this->item->id; ?>"...    <?php endif; ?></ul>

 

 

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

More
11 years 2 months ago #92433 by Casper
In the last post, are that the only things you need to add in order to show ratings to both users and guests, but only let logged in users rate the article??

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


Powered by Kunena Forum