2022-02-02, 03:31 AM
(This post was last modified: 2022-02-02, 03:41 AM by fernhafen. Edited 7 times in total.)
Dear MyBB community,
thank you in advance for taking the time to read my request...and any assistance with my customization plans
I know that the "Rate thread" feature of MyBB has many opponents, but I personally find it very useful -- because in our MyBB board (v1.8.29), we have a little subforum for "TV show ratings", where each thread represents a TV show and people use the thread rating to vote how much they like each show.
So, recently my users have requested that the threads overview on the Forum Display page not only shows each thread's current average rating, but also tells the user which rating they have given to the thread. Of course, this should only work for members and not for guests.
From what I have gathered, this variable (which is stored in the mybb_threadratings table) is not yet obtained by forumdisplay.php, so I cannot simply add something to my template...but actually need to modify the PHP file to get this data from my SQL database.
Unfortunately, my PHP/SQL knowledge is preeetttty basic, and after 2 hours of reading guides and tutorials, this is what I have added to my forumdisplay.php so far (inserting it at the bottom of the file):
...but this might be completely wrong, because adding neither {$myownrating} nor {$myownrating['tid']} to my forumdisplay_thread_rating template shows the data here.
If it isn't too much trouble...could somebody assist me with obtaining this value from the database and showing it only to members under the average star rating?
Thanks again!
thank you in advance for taking the time to read my request...and any assistance with my customization plans
I know that the "Rate thread" feature of MyBB has many opponents, but I personally find it very useful -- because in our MyBB board (v1.8.29), we have a little subforum for "TV show ratings", where each thread represents a TV show and people use the thread rating to vote how much they like each show.
So, recently my users have requested that the threads overview on the Forum Display page not only shows each thread's current average rating, but also tells the user which rating they have given to the thread. Of course, this should only work for members and not for guests.
From what I have gathered, this variable (which is stored in the mybb_threadratings table) is not yet obtained by forumdisplay.php, so I cannot simply add something to my template...but actually need to modify the PHP file to get this data from my SQL database.
Unfortunately, my PHP/SQL knowledge is preeetttty basic, and after 2 hours of reading guides and tutorials, this is what I have added to my forumdisplay.php so far (inserting it at the bottom of the file):
if($mybb->user['uid'])
{
$query = $db->simple_select("threadratings", "rating", "uid='".$mybb->user['uid']."' AND tid='".$thread['tid']."'");
$myownrating = $db->fetch_array($query);
}
else
{
$myownrating = '';
}
...but this might be completely wrong, because adding neither {$myownrating} nor {$myownrating['tid']} to my forumdisplay_thread_rating template shows the data here.
If it isn't too much trouble...could somebody assist me with obtaining this value from the database and showing it only to members under the average star rating?
Thanks again!