MyBB Community Forums

Full Version: IndexTopThreads Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am starting to create a plugin that will show a box at the top or at the botton of the index page, which will show the most viewed and most commented threads, with 5 columns each for a period of time, such as Day, Week, Month, Year and All time.

It should look more or less like this:

[Image: pluginpostsmaisacessados.jpg]

An alternative would be to make a single group and making the classification using different criterias, such as number of replies, number of views, number of thanks and maybe reputation of who thanked.

The draft (just an image) is not functional and is in portuguese, I did to show to the forum team.

I am starting with another plugin, called "index top posters", which uses similar idea, but for top posters instead of top forum.

http://mods.mybb.com/view/index-top-posters-2

I'm worried that it will be a bit of load on the index page, as I have quite a bit of guest users (usually >20.000 a day with some peaks of 70.000 a day). The "index top posters" don't use cache, but maybe it would be worth looking at.

Anyone interested in helping me? I don't have much PHP knowledge, but have programmed in many languages. I have changed a few bits and pieces of some mybb plugins, but someone more experienced helping would be awesome!

One last feature I wanted to add would be to add a small image, taken from the image on the post
Why bother ? This is already available.
(2013-02-05, 08:02 PM)Jambuster Wrote: [ -> ]Why bother ? This is already available.

Could you please show me where I can find a plugin that will do this I'm describing above?
Now that I finally got my WAMP environment with a copy of my prod mybb setup I will be able to finish this plugin. Anyone interested in helping?
It shouldnt add much load if you get your query right. You should be anle to nail all of that information in a single query qhich should be finw. Thw output would be very light as well.

You could cacge it easily either with inbuilt cacheing pr by using the pluginlibrary cache

Depending on the load that adds and again it seems a relatively small data set and a single query then I cant see it adding a whole lot..
This is the query I'm using:

Quote:$query = $db->query ("
SELECT t.subject,t.username,t.uid,t.tid,t.fid,t.lastpost,t.lastposter,t.lastposteruid,t.replies,tr.uid AS truid,tr.dateline,f.name ,TRUNCATE(t.totalratings/t.numratings*2+t.numratings/8+tyl_tnumtyls,2) ranking
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='".$mybb->user['uid']."')
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid = t.fid)
WHERE t.visible='1'
".tp_GetUnviewable("t")."
AND t.closed NOT LIKE 'moved|%'
AND t.dateline >=UNIX_TIMESTAMP()-(86400*".$days.") ORDER BY ranking DESC
LIMIT 0,".$NumOfRows);

(2013-05-10, 11:34 AM)Dannymh Wrote: [ -> ]It shouldnt add much load if you get your query right. You should be anle to nail all of that information in a single query qhich should be finw. Thw output would be very light as well.

You could cacge it easily either with inbuilt cacheing pr by using the pluginlibrary cache

Depending on the load that adds and again it seems a relatively small data set and a single query then I cant see it adding a whole lot..

It is executed 5 times, each time with the variable days with different numbers.

How works inbuilt caching?

Actually this will be executed only in the index page, and it is based on a plugin that is already on the forum.

If someone could help, in this other thread I ask how to extract the first image of a thread, and how to resize to a thumbnail with a standard size, which means that the images can be cropped to keep the height x width ratio.

http://community.mybb.com/thread-139151.html
Why not execute it once with the different day variables?
Order it by the day and then you have a row for eaxh and ordered how you want with a single entry to the database.
If you wanted to go anout it in a round about way, generate the html from a cron once a day thwn bring the raw html into the forums same result with much less overheads
(2013-05-11, 03:34 AM)Dannymh Wrote: [ -> ]Why not execute it once with the different day variables?
Order it by the day and then you have a row for eaxh and ordered how you want with a single entry to the database.
If you wanted to go anout it in a round about way, generate the html from a cron once a day thwn bring the raw html into the forums same result with much less overheads

Seems like a good idea, although the day column will need more updates.

It is looking really good, I'm fetching the image url, resizing it and adding it to the background. The post thumbnail image is then cached for future views.

I will share the plugin as it is (with a query for each column + a query to get the content and image (first time only)). I will then get people to use and test it, and get help to make it more robust.
Awesome, grabbing a little more data than you need isn't the worst thing in the world, if you have to grab a few more columns so be it, that is far better than running the same query 5 times to grab the data as that is 5 times the amount of trips to the database.
my problem now is to make the plugin robust. I have a function that makes the download of the image at the server, and creates a thumbnail of it. But if the url is invalid or is based on https the function fails and the whole page is affected, with a big error message on top of it. How can I make this function robust, to not throw an error and not affect the page?
Pages: 1 2