Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Is this possible? Displaying threads on index with x criteria
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #1
Is this possible? Displaying threads on index with x criteria
Hi everyone,

So, here is a rough mock-up of my index page concept. I want to call your attention to the "Hottest Brands" box.

[Image: wf6fJ.jpg]

The Brand Directory is a forum using xThreads.

Here are the things I would like to do.
  • Display three threads from Brands forum on index in this box
  • Have these threads ordered based on # of replies in previous [x] days
  • Display rank image of 1st, 2nd, and 3rd next to each of them (optional but desired)
  • Fetch thumbnail with exact dimensions to display with thread
  • Short description and tags are custom thread fields

It seems that RateU has accomplished pretty much exactly what I want already, except he using views as the selection method.

[Image: JFHl1.png]

I would greatly appreciate your guidance.
(This post was last modified: 05-10-2012 01:20 AM by brad-t.)
05-10-2012 01:20 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #2
RE: Is this possible? Displaying threads on index with x criteria
I suppose yes, RateU shared a file with the funtions to pull thread from x forum, you could read it and fit it to your needs (IDK in what thread he shared it).

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
05-10-2012 02:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Is this possible? Displaying threads on index with x criteria
I think that the sticking point is going to be the number of replies in X days Brad. As far as I know, MYBB stores the replies data in the threads table without a date range on the replies. You would have to make a plugin or something that calculated that for you.


[Image: leelink.gif]
MYBB1.6 & XThreads
05-10-2012 08:26 PM
Visit this user's website Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #4
RE: Is this possible? Displaying threads on index with x criteria
(05-10-2012 08:26 PM)leefish Wrote:  I think that the sticking point is going to be the number of replies in X days Brad. As far as I know, MYBB stores the replies data in the threads table without a date range on the replies. You would have to make a plugin or something that calculated that for you.

I'd be willing to pay someone to do this if you know anyone. Smile
05-11-2012 12:02 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Is this possible? Displaying threads on index with x criteria
Brad, if I knew HOW I would make it for you for free. Sadly, I do not. It can be done by querying the posts table, but that would need a cache of some sort as you are putting it on your index page, and I am failing miserably at caching. I just can't get it to work.

Maybe RateU or Sama34 could have a go at it for you (if they want to).


[Image: leelink.gif]
MYBB1.6 & XThreads
05-11-2012 03:20 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Is this possible? Displaying threads on index with x criteria
I'll try to make it a bit general (hopefully). We use XThreads functions here, (the hard things is done by XThreads Biggrin), so maybe we can use it for other XThreads applications.

Try this (attached - modify it as our needs).
Edit the file, find and and modify the value:

PHP Code:
$forumid = 2;
$xdays = 10;
$tlimit = 3;

Edit mnxt_mrtxpd_threads and/or mnxt_mrtxpd_threads_thread templates as our needs.

By default, we can find thread subject inside the mnxt_mrtxpd_threads_thread.
Use {$thread['profilelink']} for thread author username (linked to profile).

In the template, we can use {$threadfields['key']} for non attachments fields (description, category and etc), and {$threadfields['key']['item']} for attachments fields (image and/or files).

We can use something like this if we want the thumbnail displayed in the side box has a different size with the thumbnail displayed in threadlist/showthread:

HTML Code
<a href="{$thread['threadlink']}"><img src="{$threadfields['key']['thumbs']['thumbnail_size']['url']}" alt="{$thread['subject']} Preview" title="{$thread['subject']}" width="{$threadfields['key']['thumbs']['thumbnail_size']['w']}" height="{$threadfields['key']['thumbs']['thumbnail_size']['h']}" /></a>

Modify it as our needs, depends on the Key for our image custom fields. And make sure that the thumbnail size is in our Image Thumbnail Generation list settings (or we can add it there, and run the Rebuild XThreads Attachment Thumbnails tools).

{$forumurl_q} followed by filtertf_key will lead us to the forumdisplay (filtered).

Use {$thread['rank']} for the rank.
If we want to use image for the rank, we can use it something like this:

HTML Code
<img src="images/hottest_threads_{$thraed['rank']}.png" alt="" />

Then upload hottest_threads_1.png, hottest_threads_2.png, hottest_threads_3.png and etc, depends on the limit, where 1 is the hottest threads.

Please tell me if there is something wrong with the code. I'm still learning.



Attached File(s)
.php  mnxt_mrtxpd.php (Size: 4.58 KB / Downloads: 464)

05-11-2012 04:40 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Is this possible? Displaying threads on index with x criteria
whoa- that was fast. You know what I am going to ask, right? How to make this for multiple forum ids.....?

I looked in the code, I see this line:

Code:
WHERE t.fid='.intval($forumid).' AND t.visible=1 AND t.closed NOT LIKE "moved|%" AND p.visible=1 AND t.replies>0 AND p.dateline>'.$cutdate.' AND p.pid!=t.firstpost


If I was to make the fid variable a comma separated list and changed the line in the query as below, would that also work?

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if(is_array(explode(',', $forumid])))
		{
			foreach(explode(',', $forumid']) as $forum_fid)
			{
				$forum_fid_array[] = intval($forum_fid);
			}
		}
if(!empty($threadfieldscache)){
		$xtfields = '';
		foreach($threadfieldscache as &$tf){
			$xtfields .= ',tf.'.$tf['field'].' AS xthreads_'.$tf['field'];
		}
	}
	$query = $db->query('SELECT COUNT(p.pid) as posts,t.tid,t.fid,t.subject,t.username as threadusername,u.username,u.usergroup,u.displaygroup'.$xtfields.'
		FROM '.TABLE_PREFIX.'threads t
		LEFT JOIN '.TABLE_PREFIX.'threadfields_data tf ON(tf.tid=t.tid)
		LEFT JOIN '.TABLE_PREFIX.'posts p ON(p.tid=t.tid)
		LEFT JOIN '.TABLE_PREFIX.'users u ON(u.uid=t.uid)
		WHERE t.fid IN ('".implode("','", $forum_fid_array)."') AND t.visible=1 AND t.closed NOT LIKE "moved|%" AND p.visible=1 AND t.replies>0 AND p.dateline>'.$cutdate.' AND p.pid!=t.firstpost
		GROUP BY p.tid
		ORDER BY posts desc
		LIMIT 0,'.intval($tlimit).'
	');



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 05-11-2012 05:18 AM by leefish.)
05-11-2012 05:07 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Is this possible? Displaying threads on index with x criteria
I think we need to check whether a forum available for a user or not.
The plugin posted in this post is for multiple forum, Lee:
http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=531&pid=1096
We only need to change the query. It has similar method, but we need to use global threadfields cache.

(This post was last modified: 05-11-2012 05:23 AM by RateU.)
05-11-2012 05:22 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Is this possible? Displaying threads on index with x criteria
Another question - we are using the threadfields cache - so does that mean that if there is no change to the query then there will no hits on the db on page reload?

Editing to add - actually, the forums I want to use in the query are already viewable by all, except for banned users, so I could just say if banned - return you are banned (or something). So I will try it with this one.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 05-11-2012 09:54 AM by leefish.)
05-11-2012 05:32 AM
Visit this user's website Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #10
RE: Is this possible? Displaying threads on index with x criteria
Incredible, it works! Thank you!
05-11-2012 10:31 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: