View Full Version : [request] most read articles
Hi,
It is very useful if anyone can do the hack that show top 5 of most read articles(with top 5 newest article if possible) for the vbb article modules.
Thanks
phoenixdown
11-05-2004, 06:02 PM
Someone already released the latest articles as a cmps module. You can change the query around to have it select the top 5 read articles easilly enough.
Thanks for your reply! I know that module. However, I do not know how to change the query . Could you tell me a little more in detail ?
theMusicMan
11-16-2004, 06:45 PM
Edit your cmps_articles.php file such that the row that says;
ORDER BY articleid DESC LIMIT 5");
is changed to;
ORDER BY commentcount DESC LIMIT 5");
Thanks for your reply. Is is possible to display both "new articles" and " most read articles" in one block ?
theMusicMan
11-17-2004, 03:16 AM
Not really as it would use the same articles.php file to undertake the sql query that sorts the articles either by ArticleID or commentcount.
You would have to replicate that php file and give it a new name using articleid in the existing one and commentcount in the other, then create a new block which selects this new php file from the pull down selection list.
Thank you very much for you quick reply. I will try it later to night and let you know how thing is going. By the ways, dia you mean that we can not have the two things(new and most read) in a center block ?
theMusicMan
11-17-2004, 07:02 AM
Yeah, you can't unless you create a new php file to obtain the new values. You see (as far as I know - and please remember I am a willing helper not a coder...;) ) - when the portal displays the latest articles, it runs cmps_articles.php to run the query that interrogates the database that then returns the values needed to display in the Latest Articles template. These values are sorted on ArticleID.
If you want to also display the articles based on the number of comments, then you would need to retrieve the values again by running a different cmps_articles_your_version_of_this_file.php which has the changes I eluded to earlier. This would then interrogate the database and return the values needed for another Latest Article template but this time sorted in commentcount order.
So you really need 2 php files and 2 modules to do this. Sounds hard, but is easy really.... have a go... let me know how you get on.
EDIT: thought I'd have a go at describing the process for you...
1 - Replicate vb/modules/cmps_articles.php to a new file called vb/modules/cmps_articles_commentcount.php.
2 - In vb/modules/cmps_articles_commentcount.php Edit the line;
ORDER BY articleid DESC LIMIT 5");
to read
ORDER BY commentcount DESC LIMIT 5");
then save this file and upload to the vb/modules directory
3 - Create a new module called Latest Articles (comments) or something like that and use the same parameters that appear in the existing Latest Articles Module except that you select the file cmps_articles_commentcount.php from the pull down list instead of the default cmps_articles.php
4 - Enable your module and that's it.. (I think!!)
Cheers
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.