MyBB Community Forums

Full Version: Rating stars not displaying where I want
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I'm trying to display the rating stars on a thread on a different page than showthread.php but it wouldn't work. Even when using the correct generated code (the one that displays the rating stars on the showthread.php page) it still shows as a simple list (not starts like it should be).

I really don't understand why it's doing this. Can we only display them on showthread page? If yes, why?

Thank you for your time.

Here are some pictures:

What I have:

[Image: what_i_have.png]

What I want:

[Image: what_i_want.png]

Generated code (exactly the same on both pages):

[Image: generated_code.png]

And PHP code to generate the rating display (same as the one used on showthread.php):

$lang->load("ratethread");
if($thread['numratings'] <= 0)
{
    $thread['width'] = 0;
    $thread['averagerating'] = 0;
    $thread['numratings'] = 0;
}
else
{
    $thread['averagerating'] = floatval(round($thread['totalratings']/$thread['numratings'], 2));
    $thread['width'] = intval(round($thread['averagerating']))*20;
    $thread['numratings'] = intval($thread['numratings']);
}

$query = $db->simple_select("threadratings", "uid", "tid='$tid' AND uid='$uid'");
$rated = $db->fetch_field($query, 'uid');
		
$not_rated = '';
if(!$rated)
{
    $not_rated = ' star_rating_notrated';
}

$ratingvotesav = $lang->sprintf($lang->rating_average, $thread['numratings'], $thread['averagerating']);
eval("\$ratethread = \"".$templates->get("showthread_ratethread")."\";");


Using $ratethread
I could be wrong, but i think you are missing the css.
How could I miss the css? The global.css file is loaded and if you look at the picture of the code I posted, the class used are the same, and the good one.

What's puzzling me is that there is no difference between the two pages and still it's not showing.
Because the CSS for the star ratings isn't in global.css, it's in star_ratings.css
(2011-05-14, 10:57 AM)AJS Wrote: [ -> ]Because the CSS for the star ratings isn't in global.css, it's in star_ratings.css

Oh damn... You are right. How stupid is this?! Well. Do I need to "hard code" the link to the style sheet in my page template or can I call it from a plugin function or something?