Show image rating to registered users only

Phoca Gallery - image gallery extension
w1l
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 17 Mar 2011, 12:29

Show image rating to registered users only

Post by w1l »

Hi

Phoca ROCKS :-)

... in this project i need to do something a little unusual. I have categories for specific registered users ... i'd like them to be able to rate the images ... which is fine - but turning on the image rating feature so shows it to all users in all categories (even though users must be registered to rate images) ... What i'd like to do is hide the rating system from unregistered users.

The background is ... its a photography site where users can login and leave a rating for their photos, which the photographer will then view and print as marked by the rating ... i just don't want unregistered users to see image rankings in the public categories ...

Does anyone know a way to do this?

If the div holding the rating info had a class perhaps a javascript function could hide it if a users wasn't logged in? I'm not big on javascript ... so any pointers would be awesome.

I guess this is more of a feature request than anything ... but i'm in a hurry and don't mind using a hack in the short term.

thanks ya'll.
w1l
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 17 Mar 2011, 12:29

SOLVED - Re: Show image rating to registered users only

Post by w1l »

Hi all

got this to work with a bit of hacking (please forgive me Jan :x ). I see that a solution to fix this is a listed request feature, which i'm sure will get rolled into future releases ... so this is really a short term and poor solution ... but at least it'll get me project over the finish line.

1) Paste into top of - components/phocaGallery/views/category/tmpl/default.php ( i think this will may only work for a single category, not categories?). This tells joomla to use one of two styles depending on if the user is logged in or not.

<?php
$user = & JFactory::getUser();
if($user->get('guest')) {
$ratingClass = "hideGalleryRating";
} else {
$ratingClass = "showGalleryRating";
}
?>

2) paste into your style sheet (this is my cheat to hide the ratings): .hideGalleryRating { display:none; }

3) make an alt to the code (this adds the output of the php above to the div which holds the rating code): components/phocaGallery/views/category/tmpl/default.php - line:267 - class="'.$ratingClass.'"

Cheers
W
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Show image rating to registered users only

Post by Jan »

Hi, thank you for this guide.

Jan
If you find Phoca extensions useful, please support the project
Post Reply