MyBB Community Forums

Full Version: how do I use Hooks and variables in template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I posted this in the Discussion section but think I can get a better answer here Smile

I just cant get the template to read my plugin file Sad

I created:
$plugins->add_hook("usercp_menu", "userbarplugin");

and then a function called:
function userbarplugin()
{
	
	global $mybb, $db, $sotw, $theme, $lang;
	
$userbarplugin = '<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tborder2\"><tr><td class=\"thead\" colspan=\"{$colspan}\"><div class=\"theadleft\"></div><div class=\"theadright\"></div><div class=\"theadmain\"><strong>Userbar URL:</strong></div></td></tr></table><table border=\"0\" cellspacing=\"{$theme[\'borderwidth\']}\" cellpadding=\"{$theme[\'tablespace\']}\" class=\"tborder\"><tr><td class=\"trow1\" width=\"40%\"><strong>Here is your Userbar URL:</strong></td><td class=\"trow1\" width=\"60%\"><a href=\"{$mybb->settings[\'bburl\']}/userbar.php?uid={$mybb->user[\'uid\']}\">{$mybb->settings[\'bburl\']}/userbar.php?uid={$mybb->user[\'uid\'\"\"]}</a></td></tr></table><br>{$latest_warnings}';
}

But when I put {$userbarplugin} into the usercp template nothing happens Sad Am i missing something?
Use this:
function userbarplugin()
{
	global $mybb, $db, $sotw, $theme, $lang;
	
	$GLOBALS['userbarplugin'] = '...';
}
Works like a charm (at least for me). Dunno if there are any cons for this solution, but it just works.
Or just add $userbarplugin to the list of globals you've got there...
ok, someone helped me via pM Smile Thanks anyway