MyBB Community Forums

Full Version: Empty Var?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello All,
I'm doing a plugin and I've to add a var in the header template.
So I wrote this function
function logos()
{
	global $mybb;
	$banners = explode("\r\n",$mybb->settings['banners_url']);
	if(is_array($banners))
	{ 
		$rand = array_rand($banners);
		$logos = $banners[$rand];
	} 

}
This function is with the hook global_end.
But when i write {$logos} in my header template the var is empty..
What should I do?
Thanks Big Grin
Use the global_start hook.
Already Tried.. Nothing changes Sad
Using global_start hook, try this function;

function logos()
{
    global $mybb, $logos, $templates;
    $banners = explode("\r\n",$mybb->settings['banners_url']);
    if(is_array($banners))
    { 
        $rand = array_rand($banners);
        $logos = $banners[$rand];
    } 

}
Yeah, you need to global the $logo variable Smile
Thank you so much, it worked! Big Grin
No Problem Wink