MyBB Community Forums

Full Version: having trouble with $thread in showthread_start and prefixes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am trying to write a simple plugin that displays certain data if the thread has a certain prefix.

My test code doesn't seem to work

function mytipper_game_day()	{
	global $db, $thread, $mybb, $post;
	
	if(trim($thread["threadprefix"])=="Game Day")	{
		echo "This is a Game Day Thread";
	}
}
[code]

If I do the following

[code]
function mytipper_game_day()	{
	global $db, $thread, $mybb, $post;

		echo "<pre>";
		print_r($thread);
		echo "</pre>";
}

I end up with the following array

Array
(
    [tid] => 3
    [fid] => 2
    [subject] => Roosters v Manly [Round 16 2013]
    [prefix] => 1
    [icon] => 0
    [poll] => 0
    [uid] => 2
    [username] => Dan
    [dateline] => 1371794180
    [firstpost] => 4
    [lastpost] => 1371794180
    [lastposter] => Dan
    [lastposteruid] => 2
    [views] => 11
    [replies] => 0
    [closed] => 
    [sticky] => 0
    [numratings] => 0
    [totalratings] => 0
    [notes] => 
    [visible] => 1
    [unapprovedposts] => 0
    [attachmentcount] => 0
    [deletetime] => 0
    [mobile] => 0
    [threadprefix] => Game Day 
    [displayprefix] => Game Day 
)

This tells me that $thread["threadprefix] exists

If I echo out $thread["threadprefix"] it returns "Game Day ". I have tried matching with and without the space, and with and without the trim. I can not for the life of me see why I can't make a match here

Cheers
Dan

Never mind, for some truly bizarre reason, even though the $thread was global I had to add
if(!isset($thread))
	{
		$thread = get_thread((int)$mybb->input['tid']);
	}