TinyPortal
Development => Block Codes => Topic started by: khandra on October 26, 2006, 04:54:16 PM
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!
it dont show the rate tho :(
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.
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 :-\
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?
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.