Results 1 to 9 of 9

Thread: [RELEASE vB2.02beta] Bargraph thread rating

Threaded View

  1. #1
    Senior Member JWS is on a distinguished road
    Join Date
    Aug 2000
    Posts
    161
    This hack will let you have a bargraph to show ratings of threads instead of stars. In addition, it doesn't round to whole numbers and the bargraph shows smaller increments as a result.

    Here's a sample of what it looks like:



    The gist of it is this: take the average rating value (say 2.45), round it off to 1 decimal of precision (i.e. 2.4) and multiply by 10 (to get "24"). Now the width of the bargraph is set to 24 pixels wide.

    The image included as an attachment is a 1x6 image that stretches without getting distorted. You could make your own image or make variations of the image to get different results.

    Basically, you need to change the following:

    In forumdisplay.php around line 377, you'll see:

    Code:
    if ($foruminfo[allowratings]) {
             if ($thread[votenum] >= $showvotes && $thread[votenum] != 0) {
                $rating = intval(round($thread[voteavg]));
                $thread[rating] = $rating . 'stars.gif';
             } else {
                $thread[rating] = 'clear.gif';
             }
    Change this to:
    Code:
    if ($foruminfo[allowratings]) {
             if ($thread[votenum] >= $showvotes && $thread[votenum] != 0) {
                $rating = round($thread[voteavg],1);
                $bar_width = $rating * 10;
                $thread[rating] = 'bar.gif';
             } else {
                $thread[rating] = 'clear.gif';
             }
    Then in the forumdisplaybit_threadrate template, add the following parameters to the SRC tag of the image:
    Code:
    width="$bar_width" height="6"
    Hope this helps someone! It looks pretty neat!
    Jamie Sandford, editor
    Maxima.org,
    "The Home for Maxima Enthusiasts"
    http://www.maxima.org
    ------------------------------------------

    Rolling backup shell script (v2.0)
    Code to fix error when creating custom profile fields (v2.0b2)
    Code to make a bargraph rating instead of stars (v2.0b2)
     

  2. #2
    Senior Member Joe is on a distinguished road
    Join Date
    May 2000
    Location
    Highland, Utah.
    Age
    31
    Posts
    2,435
    Cool! I was going to change teh star*.gif's from stars to a bar of different lengths, i think i'll use your way, this way i can rate threads from 1-10 instead of 1-5 and the page will load faster, as it only loads one very small gif, not 10 big gifs! nice job
     

  3. #3
    Senior Member JWS is on a distinguished road
    Join Date
    Aug 2000
    Posts
    161
    Glad you like it. Just keep in mind that you'll need to widen the <td> width of the column for the ratings if you go up to 10. Other than that, you should be good to go!

    Originally posted by Joe
    Cool! I was going to change teh star*.gif's from stars to a bar of different lengths, i think i'll use your way, this way i can rate threads from 1-10 instead of 1-5 and the page will load faster, as it only loads one very small gif, not 10 big gifs! nice job
    Jamie Sandford, editor
    Maxima.org,
    "The Home for Maxima Enthusiasts"
    http://www.maxima.org
    ------------------------------------------

    Rolling backup shell script (v2.0)
    Code to fix error when creating custom profile fields (v2.0b2)
    Code to make a bargraph rating instead of stars (v2.0b2)
     

  4. #4
    Senior Member Joe is on a distinguished road
    Join Date
    May 2000
    Location
    Highland, Utah.
    Age
    31
    Posts
    2,435
    Couldnt i just times the gif size by 5, instead of 10? Maybe i will stick to a 5 choice rating *shrug* i'll have to think about it .
     

  5. #5
    Senior Member JWS is on a distinguished road
    Join Date
    Aug 2000
    Posts
    161
    No, because the "*10" gets the decimal into the ones place so that you can set the width. Doing it by 5 would just get you another decimal possibly and you can't set a width to a decimal place.

    Just make sure that the table cell width coincides with how big you're making your bar and you'll be fine.

    Originally posted by Joe
    Couldnt i just times the gif size by 5, instead of 10? Maybe i will stick to a 5 choice rating *shrug* i'll have to think about it .
    Jamie Sandford, editor
    Maxima.org,
    "The Home for Maxima Enthusiasts"
    http://www.maxima.org
    ------------------------------------------

    Rolling backup shell script (v2.0)
    Code to fix error when creating custom profile fields (v2.0b2)
    Code to make a bargraph rating instead of stars (v2.0b2)
     

  6. #6
    Senior Member Joe is on a distinguished road
    Join Date
    May 2000
    Location
    Highland, Utah.
    Age
    31
    Posts
    2,435
    ahh, thanks heh
     

  7. #7
    Senior Member mrlister is on a distinguished road mrlister's Avatar
    Join Date
    Nov 2000
    Location
    Burnaby, BC
    Posts
    371
    thx man. great job
     

  8. #8
    Senior Member Thomas P is on a distinguished road Thomas P's Avatar
    Join Date
    Apr 2001
    Location
    Munich, DE
    Posts
    1,489
    Thanks JWS,

    works very well on 2.0.3.

    It's around 451 in 2.0.3 and here are the slightly different changes:

    Find:
    PHP Code:
          if ($foruminfo[allowratings]) {
             if (
    $thread[votenum] >= $showvotes) {
                
    $rating intval(round($thread[voteavg]));
                
    $thread[rating] = $rating 'stars.gif';
             } else {
                
    $thread[rating] = 'clear.gif';
             } 
    Change to:
    PHP Code:
    if ($foruminfo[allowratings]) {
             if (
    $thread[votenum] >= $showvotes) {
                
    $rating round($thread[voteavg],1);
                
    $bar_width $rating 10;
                
    $thread[rating] = 'bar.gif';
             } else {
                
    $thread[rating] = 'clear.gif';
             } 
    cu,
    -Tom
    www.MCSEboard.de
    German Windows Server & IT Pro Community dedicated to Windows Client & Server Systems. MVPs inside
     

  9. #9
    Senior Member JamesUS is on a distinguished road
    Join Date
    Aug 2000
    Location
    London, England
    Posts
    4,625
    Moved into the releases forum for you
    James Ussher-Smith
    .:.: SideLinks - Make your directory work for you :.:.
     

Similar Threads

  1. [Release v2] In-Thread Rating
    By tubedogg in forum Releases: Version 2.x
    Replies: 39
    Last Post: Mon 29th Oct '01, 9:06pm
  2. [Release VB2] Total Thread Views
    By SystemLogic in forum Releases: Version 2.x
    Replies: 54
    Last Post: Fri 12th Oct '01, 10:49pm
  3. Replies: 12
    Last Post: Wed 1st Aug '01, 5:39am

Bookmarks

Posting Permissions

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts