MyBB Community Forums

Full Version: Using Xthreads with Recent Threads On Index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello, 

I am using Xthreads with Recent Threads On Index  Recent Threads On Index  Recent Threads On Index Recent Threads On Index


http://community.mybb.com/thread-159857.html


http://mybbhacks.zingaburga.com/showthread.php?tid=288

but my globals are not showing up in the plugin, but working on the forums


Quote: Wrote:{$GLOBALS['threadfields']['key']}

help please
You need to edit the plugin to also join to the xthreads threadfields data.
herrmm this noob needs a bit of help on that...Can you show example please LOL
You can always post in the plugin release thread and ask the plugin author; that is rather more appropriate Smile
I've never used XThreads. If he just needs to do a table join, I might be able to find a way. If its something else, I'm not certain.
hi i added a field to the post, and would like to display it on the index !! along with the topic title, author etc

thanks
Assuming it is on the first post of the thread and added field is in the mybb_posts table, find:
$query = $db->query("
			SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, u.avatar as threadavatar, u.avatardimensions as threaddimensions, lp.usergroup AS lastusergroup, lp.avatar as lastavatar, lp.avatardimensions as lastdimensions, lp.displaygroup as lastdisplaygroup
			FROM ".TABLE_PREFIX."threads t
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
			LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
			WHERE 1=1 $where AND t.visible > {$approved} {$unsearchableforumssql} {$ignoreforums}
			ORDER BY t.lastpost DESC
			LIMIT $threadlimit
		");

replace with:
$query = $db->query("
			SELECT t.*, p.*, u.username AS userusername, u.usergroup, u.displaygroup, u.avatar as threadavatar, u.avatardimensions as threaddimensions, lp.usergroup AS lastusergroup, lp.avatar as lastavatar, lp.avatardimensions as lastdimensions, lp.displaygroup as lastdisplaygroup
			FROM ".TABLE_PREFIX."threads t
LEFT JOIN " . TABLE_PREFIX . "posts p ON(t.firstpost=p.pid)
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
			LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
			WHERE 1=1 $where AND t.visible > {$approved} {$unsearchableforumssql} {$ignoreforums}
			ORDER BY t.lastpost DESC
			LIMIT $threadlimit
		");

You can get the title with {$thread['subject']}. Thread author is {$thread['author']}, but keep in mind that formats the name according to their usergroup and makes it a link. If you just want the plain text author, use {$thread['userusername']}.
Quote:{$GLOBALS['threadfields']['key']}

well i have no idea where the data is, could be in the post or its own metadata table?

and i just need my new field, the others are displayed as out of the box, (i re formatted it a bit so dunno if AJAX is working or not LOL

// only 'username' and 'fid' keys are used from the $thread array
function xthreads_get_threadfields($tid, &$threadfields, $noextra=true, $thread=array()) {
	$tid = (int)$tid;
	if(!$tid) return;
	
	if(empty($thread))
		$thread = get_thread($tid);
	
	if($thread['fid'] == $GLOBALS['fid']) // use global cache if we're referring to current forum
		$threadfield_cache =& $GLOBALS['threadfield_cache'];
	if(!isset($threadfield_cache))
		$threadfield_cache = xthreads_gettfcache((int)$thread['fid']);
	
	if(!empty($threadfield_cache)) {
		global $db;
		$threadfields = $db->fetch_array($db->simple_select('threadfields_data', '`'.implode('`,`', array_keys($threadfield_cache)).'`', 'tid='.$tid));
		if(!isset($threadfields)) $threadfields = array();
		foreach($threadfield_cache as $k => &$v) {
			xthreads_get_xta_cache($v, $tid);
			xthreads_sanitize_disp($threadfields[$k], $v, $thread['username'], $noextra);
		}
	}
}
@dragonexpert Would you be able to provide a solution to this? Allowing xthreads {$GLOBALS['threadfields']['key']} to be used in Recent Threads On Index templates.
You can access any field in the mybb_threads table though. Just use {$thread['fieldname']}.
Pages: 1 2