Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Replace 5 Star rating with single VOTE button.  (Read 10912 times)

0 Members and 1 Guest are viewing this topic.

mustang_lex

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
    • Stangette.com
Replace 5 Star rating with single VOTE button.
« 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.
Logged
Alex
www.stangette.com/showcase
my Coppermine Gallery!

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Replace 5 Star rating with single VOTE button.
« Reply #1 on: August 07, 2008, 07:40:11 am »

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
Code: [Select]
$template_image_ratingand edit as suggested below. If that section doesn't exist in your custom theme, copy
Code: [Select]
// 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
Code: [Select]
?>Then edit as you see fit. In your case, remove the unwanted stuff, i.e. replace the code mentioned above with
Code: [Select]
// 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 ;).
Logged

mustang_lexx

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Replace 5 Star rating with single VOTE button.
« Reply #2 on: August 11, 2008, 01:43:14 am »

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
Code: [Select]
// 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. (http://www.stangette.com/v2/showcase/images/vote.gif)
Upload both the vote.gif image and theme.php file.

2) Edit english.php file under lang (or whatever language file you have)

find
Code: [Select]
'rating' => '(current rating : %s / 5 with %s votes)',

replace with
Code: [Select]
'rating' => '(current rating : %s votes)',

save and upload

3) edit themes.inc.php located in the includes folder.

find
Code: [Select]
$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
Code: [Select]
$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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Replace 5 Star rating with single VOTE button.
« Reply #3 on: August 11, 2008, 07:02:15 am »

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.
Logged

Marc_UK

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Replace 5 Star rating with single VOTE button.
« Reply #4 on: August 15, 2008, 10:47:08 am »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Replace 5 Star rating with single VOTE button.
« Reply #5 on: August 23, 2008, 09:40:45 am »

Not related to the mod discussed in this thread. Please don't hijack this thread, but start a new one for your different request.
Logged

davieb

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Replace 5 Star rating with single VOTE button.
« Reply #6 on: December 21, 2008, 09:38:27 am »

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?
Logged

davieb

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Replace 5 Star rating with single VOTE button.
« Reply #7 on: December 23, 2008, 07:50:48 pm »

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?
Logged

Nibbler

  • Guest
Re: Replace 5 Star rating with single VOTE button.
« Reply #8 on: December 23, 2008, 08:03:19 pm »

Same reply applies as above. What you are asking for is not related to this mod, so post a new thread.
Logged

davieb

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Replace 5 Star rating with single VOTE button.
« Reply #9 on: December 24, 2008, 02:43:25 pm »

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  :'(
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Replace 5 Star rating with single VOTE button.
« Reply #10 on: December 27, 2008, 10:48:33 am »

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 19 queries.