Top 10 topics on index page with thread images?
#1 28-05-2014 
Hi Lee,

Spoke to you in the chat section late last night about this, so here's some more detail.

I want to be able to show the top 10 most replied to topics on the index page, and I want those topics to be represented by their thread image. I'm using the XThreads plugin and have created a custom field for uploading an image when creating a thread. So that all works fine.

I was unable to find a plugin anywhere to show the top 'replied to' threads on the index page or in the portal, so I'm currently using a Polish plugin called 'TopStats', and this works to show the top replied to threads, either on the index page or in the portal.

But my knowledge of php falls down completely at this stage, and I don't know how to get the Polish plugin to show the thread image. It shows the avatar, thread title, poster, and time, but all I want it to show is the image, title, and number of replies. I can then design the area to look how I want.

If you know of a completely separate way of showing the top replied to threads on the index page WITH their images and WITHOUT the need for the Polish plugin I'm using, then that would be perfect. Please let me know what you need to see from me in order to help me before I hang myself. Haha!

thredder, proud to be a member of LeeFish since May 2014.
(This post was last modified: 28-05-2014 04:26 PM by leefish.)

#2 28-05-2014 
What you can use is the gallery plugin. It creates a simple set of templates. The sort by a.aid in the query needs to be changed to sort by t.views. Then you can style it as you go.

Download the gallery plugin
Open the file and find this query:

$query = $db->query("
            SELECT a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, a.thumbs, a.field, t.*
            FROM ".TABLE_PREFIX."xtattachments a
            LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
            WHERE t.visible=1 AND a.thumbs!=' ' AND t.closed NOT LIKE 'moved|%' AND t.fid IN ('".implode("','", $fishhattatgal_tid_array)."')
            GROUP BY t.tid
            ORDER BY a.aid DESC
            LIMIT $fishhattatgal_num

and change ORDER BY a.aid DESC to ORDER BY t.views DESC

and it should work.

#3 28-05-2014 

That sort of works - the area does display at the top of the index page - but all it shows are the thread titles, not the images.

Also, how would it display only the threads with the most replies?

Apologies, it does pull the threads with the most replies.

What would I do to the area if I want the plugin to just show the image, the number of replies, and the title?
(This post was last modified: 28-05-2014 02:26 PM by thredder.)

#4 28-05-2014 
We are getting close to custom plugin area nowTongue

Is this index page in your forum? Or is it in a higher level page? If it is then you need to fix the urls set up in the custom threadfields. If it isn't then that is another issue and it should work. Bear in mind that the thumbnail size is hardcoded to 160x120. If that image size isn't in your setup then you can open the plugin file and find this line:

$fishhatt_att_thumb = xthreads_get_xta_url($fishhatt).'/thumb160x120';

and change the thumb??x??? to a size you have. Example:

$fishhatt_att_thumb = xthreads_get_xta_url($fishhatt).'/thumb320x240';

#5 28-05-2014 
Just worked that out myself, haha.

I actually want the images to show at full size so I can control them myself with css, and they're doing that now.

It's an excellent plugin as it'll only show the threads with an image, so that eliminates the worry about the area showing gaps where images should be.

Still need to put the replies number and the title in the area. Also, how would I go about adding a restriction to the timeframe? In other words, it currently just pulls them from all time, but how about if it was to only show top replies for that day, week, or month?

Thanks Lee, I really do appreciate your help, it's a massive relief. If I have to pay you for it then please just let me know.

#6 28-05-2014 
That is where things get fiddly. MyBB doesnt actually measure the number of views using a date field; it increments the field in the threads, so though I could make the plugin look for threads only created in the last month (or images uploaded in the last month) I cant make it query on the number of views this week without a lot of edits. Is created time ok?

#7 28-05-2014 
Hmm... I'm basically attempting to have the content 'refresh' daily depending on who's discussing what, so the order of threads would change as people discuss a certain topic one day and so on. Is there nothing at all I could combine with this so that it checks for threads replied to between two times (midnight one day to 11.59pm the next, for example)?

If not, then created time would probably be better than nothing, as otherwise the homepage would always just show the threads most replied to for all time.


#8 28-05-2014 
Its the weight of the query; in order to make your idea work you would then have to query the posts table; depending on the size of the query it might slow your forum. Imagine - it would hit the posts table on EVERY load of the index. Are these threads all in one forum or all over the board?

Its doable - everything is - its just whether it is wise to do so.

#9 28-05-2014 
They're spread over about 5 different parts of the forum.

#10 28-05-2014 
ok, load of coding gobbledygook coming Tongue

The views in a time frame are recorded nowhere in MyBB. There is a plugin (not free) that actually creates a new table and tracks the trending in a fixed timeframe. If you had that plugin (and its table) then I could adjust the query of the gallery plugin to pull the data.

You can get it by subscribing to Pavemen's forum here: COST: 7.50.

Sorry, that is a members only option