MyBB Community Forums

Full Version: Define variable and using it in forumbit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I createing plugin for getting 5 latest post for each category and show it in own forumbit. I define variable in function which added to functions_forumlist.php with add_hook("build_forumbits_forum", "functionname"); but i can't use it in forumbit templates.

Example code;
$plugins->add_hook('build_forumbits_forum', 'example');
function example($forum)
{
global $myvar;
$myvar = "Hello World!";
}

When i use it such example forumbit_depth1_cat it doesn't showing on forumlist.
I'm not sure, but maybe you could do this:
function example($forum)
{
$forum['myvar'] = "Hello World!";
return $forum;
}
to add your variable. Be careful with the key‘s name.
(2020-01-20, 12:12 PM)noyle Wrote: [ -> ]I'm not sure, but maybe you could do this:
function example($forum)
{
$forum['myvar'] = "Hello World!";
return $forum;
}
to add your variable. Be careful with the key‘s name.

Thanks lot! Define inline variable fix the problem.