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: Rating below thumbnail  (Read 3239 times)

0 Members and 1 Guest are viewing this topic.

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Rating below thumbnail
« on: December 01, 2011, 04:22:21 pm »

Hi,

Right now you can see the Rating stars and the number of voted underneath the thumbnail.

What I want is to add the rating number.

So under the thumbnail you see => (2 votes) change into (2 votes, 9.3)

Thanks,

Edward
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Rating below thumbnail
« Reply #1 on: December 02, 2011, 01:04:42 pm »

Open include/functions.inc.php and find
Code: [Select]
        if (in_array('pic_rating', $must_have)) {

            if (defined('THEME_HAS_RATING_GRAPHICS')) {
                $prefix = $THEME_DIR;
            } else {
                $prefix = '';
            }

            //calculate required amount of stars in picinfo
            $rating        = round(($row['pic_rating'] / 2000) / (5 / $CONFIG['rating_stars_amount']));
            $rating_images = '';

            for ($i = 1; $i <= $CONFIG['rating_stars_amount']; $i++) {

                if ($i <= $rating) {
                    $rating_images .= '<img src="' . $prefix . 'images/rate_full.png" alt="' . $rating . '"/>';
                } else {
                    $rating_images .= '<img src="' . $prefix . 'images/rate_empty.png" alt="' . $rating . '"/>';
                }
            }

            $caption .= '<span class="thumb_caption">' . $rating_images . '<br />' . sprintf($lang_get_pic_data['n_votes'], $row['votes']) . '</span>';
        }

The last line is the important one to add custom content. We need to know how you calculate the displayed rating number. What's the best possible rating? I assume 10?
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Rating below thumbnail
« Reply #2 on: December 02, 2011, 02:09:40 pm »

Yes 10
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Rating below thumbnail
« Reply #3 on: December 02, 2011, 02:21:36 pm »

How many decimal places have to be displayed at maximum?

Just add
Code: [Select]
$caption = substr($caption, 0, -8).", ".round(($row['pic_rating'] / 1000), 1).")</span>";below
Code: [Select]
$caption .= '<span class="thumb_caption">' . $rating_images . '<br />' . sprintf($lang_get_pic_data['n_votes'], $row['votes']) . '</span>';to display 1 decimal place.
« Last Edit: December 02, 2011, 02:27:32 pm by Αndré »
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Rating below thumbnail
« Reply #4 on: December 02, 2011, 02:30:37 pm »

1 decimal
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Rating below thumbnail
« Reply #5 on: December 02, 2011, 02:59:50 pm »

Seems that you missed the edit in my previous posting.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Rating below thumbnail
« Reply #6 on: December 02, 2011, 04:53:59 pm »

Changed some things:

 $caption .= '<span class="thumb_caption">' . '</br>' . '<center>'. $rating_images . '<br />' . sprintf($lang_get_pic_data['n_votes'], $row['votes']) . ", rating ".round(($row['pic_rating'] / 1000), 1).")</span>" . '</center>';

This results into:

(2 votes), rating 7.3)

How do I get ride of the ")" after the votes ??
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Rating below thumbnail
« Reply #7 on: December 02, 2011, 04:58:14 pm »

How do I get ride of the ")" after the votes ??
With the above mentioned code.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Rating below thumbnail
« Reply #8 on: December 02, 2011, 05:09:39 pm »

With the above code it looks like this:

(2 votes)<, 8)

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Rating below thumbnail
« Reply #9 on: December 02, 2011, 05:16:57 pm »

Please undo your modifications and just apply my code for a start. Then you'll see that it works as expected and then add your further customizations.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Rating below thumbnail
« Reply #10 on: December 02, 2011, 05:35:01 pm »

Yep you are right...
It works now..

Thank you Andre
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 19 queries.