Rating below thumbnail Rating below thumbnail
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Rating below thumbnail

Started by altenae, December 01, 2011, 04:22:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

altenae

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

Αndré

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?

altenae


Αndré

#3
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.

altenae


Αndré

Seems that you missed the edit in my previous posting.

altenae

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

Αndré

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.

altenae

With the above code it looks like this:

(2 votes)<, 8)


Αndré

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.

altenae

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

Thank you Andre