coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: altenae on December 01, 2011, 04:22:21 PM

Title: Rating below thumbnail
Post by: altenae 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
Title: Re: Rating below thumbnail
Post by: Αndré on December 02, 2011, 01:04:42 PM
Open include/functions.inc.php and find
        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?
Title: Re: Rating below thumbnail
Post by: altenae on December 02, 2011, 02:09:40 PM
Yes 10
Title: Re: Rating below thumbnail
Post by: Αndré on December 02, 2011, 02:21:36 PM
How many decimal places have to be displayed at maximum?

Just add
$caption = substr($caption, 0, -8).", ".round(($row['pic_rating'] / 1000), 1).")</span>";
below
$caption .= '<span class="thumb_caption">' . $rating_images . '<br />' . sprintf($lang_get_pic_data['n_votes'], $row['votes']) . '</span>';
to display 1 decimal place.
Title: Re: Rating below thumbnail
Post by: altenae on December 02, 2011, 02:30:37 PM
1 decimal
Title: Re: Rating below thumbnail
Post by: Αndré on December 02, 2011, 02:59:50 PM
Seems that you missed the edit in my previous posting.
Title: Re: Rating below thumbnail
Post by: altenae 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 ??
Title: Re: Rating below thumbnail
Post by: Αndré on December 02, 2011, 04:58:14 PM
Quote from: altenae on December 02, 2011, 04:53:59 PM
How do I get ride of the ")" after the votes ??
With the above mentioned code.
Title: Re: Rating below thumbnail
Post by: altenae on December 02, 2011, 05:09:39 PM
With the above code it looks like this:

(2 votes)<, 8)

Title: Re: Rating below thumbnail
Post by: Αndré 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.
Title: Re: Rating below thumbnail
Post by: altenae on December 02, 2011, 05:35:01 PM
Yep you are right...
It works now..

Thank you Andre