Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
rating
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2020-11-21 22:25:32
Hello, I'm looking for the piece of code to put in function.php so that the stars of the votes appear in the torrent.php page.
2020-11-21 22:50:46
Heres the current function already in v3
function ratingpic($num)
{
   global $config;
   $r = round($num * 2) / 2;
   if ($r != $num) {
       $n = $num - $r;
       if ($n < .25) {
           $n = 0;
       } elseif ($n >= .25 && $n < .75) {
           $n = .5;
       }

       $r += $n;
   }
   if ($r < 1 || $r > 5) {
       return;
   }

   return "<img src=\"" . $config["SITEURL"] . "/images/rating/$r.png\" border=\"0\" alt=\"rating: $num/5\" title=\"rating: $num/5\" />";
}


You just need to pass the rating number from the big query depending where you want it example
echo ratingpic($row['numratings']);
2020-11-21 23:29:57
thanks for the help I just made the modification and the stars don't show in the torrent page on torrent.php:rolleyes:
2020-11-22 03:15:14
Mine (and im overriding star colour by users current theme):


function ratingpic($num)
{
   global $CONFIG;
   $r = round($num * 2) / 2;
   if ($r != $num) {
       $n = $num - $r;
       if ($n < .25)
           $n = 0;
       elseif ($n >= .25 && $n < .75)
           $n = .5;
       $r += $n;
   }
   if ($r < 1 || $r > 5)
       return;
   
   return "<div class=\"stars-rating\" style=\"--rating: $num;padding-bottom:7px\" aria-label=\"Rating is $num / 5\"></div>";
}
2020-11-22 06:18:14
"niki, post: 69594, member: 20338":

thanks for the help I just made the modification and the stars don't show in the torrent page on torrent.php:rolleyes:


:unsure:  maybe we can be more clear
For torrent.php it would be in torrenttable correct, if so on config.php find
$site_config["torrenttable_columns"]


Add rating to end off that line  and it will show on index, torrents, search etc

If not torrenttable a image of location will help  (y)
2020-11-22 11:19:32
thanks for the help and here is the code part of the config.php file and what do I have to add in it?


// category = Category Image/Name, name = Torrent Name, dl = Download Link, uploader, comments = # of comments, completed = times completed, size, seeders, leechers, health = seeder/leecher ratio, external, wait = Wait Time (if enabled), rating = Torrent Rating, added = Date Added, nfo = link to nfo (if exists)
$site_config["torrenttable_columns"] = "tube,category,cover,name,dl,uploader,comments,size,seeders,leechers,health,external";
// size, speed, added = Date Added, tracker, completed = times completed
$site_config["torrenttable_expand"] = "";
2020-11-22 11:53:57
Try replace line in config.php with this I have added rating
$site_config["torrenttable_columns"] = "tube,category,cover,name,dl,uploader,comments,size,seeders,leechers,health,external,rating";


Now it should show on torrenttable
2020-11-22 14:10:37
thanks for your help, everything is ok and works well now (y):D


[ATTACH type="full"]5968[/ATTACH]
1606054125411.png
1606054125411.png
2020-11-22 15:19:33
still a small request, it is necessary to note twice for the stars to be visible, can you tell me if it is possible to make the stars visible when you note only once :rolleyes:
2020-11-22 16:38:57
You can try swap this part about in functions.php find
                case 'rating':
                   if (!$row["rating"]) {
                       $rating = "--";
                   } else {
                       $rating = "<a title='$row[rating]/5'>" . ratingpic($row["rating"]) . "</a>";
                   }

                   //$rating = ratingpic($row["rating"]);
                   //$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
                   print("<td class='ttable_col$x' align='center'>$rating</td>");
                   break;
           }


I have put // before 3 lines
Remove the // one at a time maybe we get lucky
                case 'rating':
                   if (!$row["rating"]) {
                       $rating = "--";
                   } else {
                       // $rating = "<a title='$row[rating]/5'>" . ratingpic($row["rating"]) . "</a>";
                   // $rating = ratingpic($row["rating"]);
                   // $rating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
                   }
                   print("<td class='ttable_col$x' align='center'>$rating</td>");
                   break;
           }
2020-11-22 17:08:16
I think this is the part to edit. $x equals 2
case 'rating':
               if (!$row["rating"])
                   $rating = "--";
               else
                   $rating = "<a title='$row[rating]/5'>".ratingpic($row["rating"])."</a>";
                   //$rating = ratingpic($row["rating"]);
                    //$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
               print("<td class='ttable_col$x' align='center'>$rating</td>");
           break;
       }
       if ($x == 2)
           $x--;
       else
           $x++;

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-11-22 17:31:06
I have a pure CSS solution that using a ACII star character, it’s 100% cross-compatible and just requires the ratingpic() function. Easy to drop in as it’s just HTML and a few CSS properties. Very customizable and no-images.
2020-11-22 17:51:19
I tried both proposals and it does not work it is always necessary to note the torrent 2 times for the stars to be displayed, maybe see with the solution and css of STorrents2020 :rolleyes:
2020-11-22 18:22:16
It’s CSS3, you can’t go wrong. I’ll post in shortly
2020-11-22 19:21:24
thank you all very much for your help
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728