TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 01, 2024, 06:58:51 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 167
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 150
  • Total: 150

Most rated articles

Started by khandra, October 26, 2006, 04:54:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

khandra

A very quick mod to show a list of the 5 (in this case) most viewed articles. Note that articles must have view count enabled to be shows here. The title is cut to 30 chars of length.
To change the number of articles modify "LIMIT 5" with your number.


$request = db_query("SELECT * FROM smf_tp_articles WHERE approved = 1 AND off = 0 ORDER BY rating DESC LIMIT 5", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
  while($row = mysql_fetch_assoc($request)){
    if(strstr($row['options'], 'rating') != FALSE)
    {
      echo '<a href="' . $scripturl . '?page='.$row['id'].'">'.substr($row['subject'], 0, 30).'</a>';
      echo "<br>";
    }
  }
}


Hope this helps!

Assistance


khandra

No, it does not! It just show an hyperlink to the article. I do not need the rate too. But it is easy to add:
Modify this code:
echo '<a href="' . $scripturl . '?page='.$row['id'].'">'.substr($row['subject'], 0, 30).'</a>';
      echo "<br>";

with:

echo '<a href="' . $scripturl . '?page='.$row['id'].'">'.substr($row['subject'], 0, 30).'</a>: '.$row['rating'];
      echo "<br>";

I have not tested this last code, but I hope it works.

knat

#3
Where do i enable viewcount for articles ?

I can see inside the article how many viewed it but i cant get the code to show  :-\

koolaid

Quote from: khandra on October 30, 2006, 07:53:34 AM
No, it does not! It just show an hyperlink to the article. I do not need the rate too. But it is easy to add:
Modify this code:
echo '<a href="' . $scripturl . '?page='.$row['id'].'">'.substr($row['subject'], 0, 30).'</a>';
      echo "<br>";

with:

echo '<a href="' . $scripturl . '?page='.$row['id'].'">'.substr($row['subject'], 0, 30).'</a>: '.$row['rating'];
      echo "<br>";

I have not tested this last code, but I hope it works.

The above code doesn't show the rating. Anyone know how to get it to show the rating as well?

Ken.

koolaid this topic is more than one year old and the information here is no longer valid. Please do a search for your question and you'll find your answer.

Another way would be to simply explore the article controls in your admin panel because that would also give you your answer.



Please Note:
This topic is over one year old so if you have a similar question please do a search or start a new topic.
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.