forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: mustang_lex on August 07, 2008, 06:15:53 am
-
Hey Guys. I need to replace 5 star rating with a single VOTE button. On an older coppermine version I was able to remove 1-4 buttons, and change the 5 button to be just a vote button. I still have the graphic button, but I don't know which file to edit in 1.4.
Thank You in advance.
-
Pretty straigforward hack - the method hasn't changed over the versions. I don't remember older threads, so I'll re-post the instructions: edit themes/yourtheme/theme.php, find
$template_image_rating
and edit as suggested below. If that section doesn't exist in your custom theme, copy// HTML template for the image rating box
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td colspan="6" class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE0}" title="{RUBBISH}" rel="nofollow"><img src="{LOCATION}images/rating0.gif" border="0" alt="{RUBBISH}" /><br /></a></td>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE1}" title="{POOR}" rel="nofollow"><img src="{LOCATION}images/rating1.gif" border="0" alt="{POOR}" /><br /></a></td>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE2}" title="{FAIR}" rel="nofollow"><img src="{LOCATION}images/rating2.gif" border="0" alt="{FAIR}" /><br /></a></td>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE3}" title="{GOOD}" rel="nofollow"><img src="{LOCATION}images/rating3.gif" border="0" alt="{GOOD}" /><br /></a></td>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE4}" title="{EXCELLENT}" rel="nofollow"><img src="{LOCATION}images/rating4.gif" border="0" alt="{EXCELLENT}" /><br /></a></td>
<td class="tableb_compact" width="17%" align="center"><a href="{RATE5}" title="{GREAT}" rel="nofollow"><img src="{LOCATION}images/rating5.gif" border="0" alt="{GREAT}" /><br /></a></td>
</tr>
</table>
EOT;
from themes/sample/theme.php into themes/yourtheme/theme.php, into a new line before?>
Then edit as you see fit. In your case, remove the unwanted stuff, i.e. replace the code mentioned above with// HTML template for the image rating box
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact" align="center"><a href="{RATE1}" title="{GREAT}" rel="nofollow"><img src="{LOCATION}images/rating1.gif" border="0" alt="{GREAT}" /><br /></a></td>
</tr>
</table>
EOT;
Of course you might have to edit the icon and textual labels.
The above hack will offer only two choices: you rate or you don't. However, the stats showing in other places will display something else, saying that a file has been rated 5 / 5 with X votes, which is of course a bit misleading. The deal is the same: find the corresponding section of code that needs changing (search themes/sample/theme.php for it), then copy the section you want to see changed (and only that section) into your custom theme and finally change it as you see fit. I'm looking forward to see you complete the rest of the hack on your own - please post your results ;).
-
With the help from both Joachim Müller and Nibbler (from when I did the same thing in ver 1.3) I have a solution and works perfect. Here are the steps.
First before I begin, this modification will remove a 5 star rating to a single VOTE system. This will replace the line where is normally says "Rate this file (current rating : 1 / 5 with 2 votes)" to "Rate this file (current rating : 2 votes)" and remove the images you see with the 1-5 star under the thumbnail in "Top Rated" area.
1) Add code that will replace all 5 star buttons with 1 vote button.
Open themes.php located in your current theme folder and add
// HTML template for the image rating box
$template_image_rating = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
<tr>
<td class="tableh2_compact"><b>{TITLE}</b> {VOTES}</td>
</tr>
<tr>
<td class="tableb_compact" align="center"><a href="{RATE1}" title="{GREAT}" rel="nofollow"><img src="{LOCATION}images/vote.gif" border="0" alt="{GREAT}" /><br /></a></td>
</tr>
</table>
EOT;
You can use this vote.gif button if you like or upload your own to the images folder. (https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.stangette.com%2Fv2%2Fshowcase%2Fimages%2Fvote.gif&hash=0946b334a1a140cbc7c45de3a9b0befd467bc0e2)
Upload both the vote.gif image and theme.php file.
2) Edit english.php file under lang (or whatever language file you have)
find
'rating' => '(current rating : %s / 5 with %s votes)',
replace with
'rating' => '(current rating : %s votes)',
save and upload
3) edit themes.inc.php located in the includes folder.
find
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1),
$CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
replace with
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes']; $pid =
$CURRENT_PIC_DATA['pid'];
save and upload.
4) Finally I created a new gif image with 100% transparency and saved it as rating0.gif, rating1.gif, rating2.gif, rating3.gif, rating4.gif and rating5.gif
I uploaded the new files to image folder over writing the old ones. This is so you wouldn't see the rating images on the "Top Rating" page. I'm sure the is a more "proper" way such as removing the code itself but I found this easier and faster. If you do not know how to create gif, save the files from these locations
http://www.stangette.com/v2/showcase/images/rating0.gif
http://www.stangette.com/v2/showcase/images/rating1.gif
http://www.stangette.com/v2/showcase/images/rating2.gif
http://www.stangette.com/v2/showcase/images/rating3.gif
http://www.stangette.com/v2/showcase/images/rating4.gif
http://www.stangette.com/v2/showcase/images/rating5.gif
Right click and save link as because you wont see the image since it is transparent and will work with any theme. Upload them to the main images folder.
And voila. You can see an example at http://www.stangette.com/v2/showcase/index.php but you will have to creat an account to see the single vote
mod.
I hope this help anyone out there and thanks again to Joachim Müller and Nibbler for helping me out.
-
Thanks for your readiness to contribute.
Downloaded the rating icons and put them into a zip archive. Attached the archive to my posting. That's much easier and will prevent the thread becoming useless in case your link goes down.
-
This is great, but is there a way of modifying it so 1 user only gets to vote on 1 picture in an album instead of all of pictures?
Regards
Marc
-
Not related to the mod discussed in this thread. Please don't hijack this thread, but start a new one for your different request.
-
Great this works a treat and is easy enough to follow.
One question, is there a way to make a "Thank you for voting" message appear instead of just having the screen refresh?
-
One question, is there a way to make a "Thank you for voting" message appear instead of just having the screen refresh?
Anyone? Or do I just assume that the lack of replies means it can't be done?
-
Same reply applies as above. What you are asking for is not related to this mod, so post a new thread.
-
Don't see how it's not related as it is something which occurs (or doesn't) when you click new button that is part of this thread but ok :'(
-
Not doing as supporters suggest and trying to argue instead about instructions posted by forum staff members is a very silly attitude, as it makes it much less likely that someone will be willing to look into your individual issues. Locking.