MyBB Community Forums

Full Version: problem with hook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys I'm making a plugin and I have a problem with hook, this is the code:

$plugins->add_hook("build_forumbits_forum", "ficon_icon");

function ficon_icon() {
    global $forum, $ficon, $templates;

    if($forum['icon_url'] != "") {
        eval('$ficon = "'.$templates->get('ficon_index').'";');
    } else {
        $ficon = "<small>Forum Icon</small>";
    }
}

It don't show me any error and don't show me template or text "Forum Icon", how I can fix it?
Instead of

eval('$ficon = "'.$templates->get('ficon_index').'";');

Try this

eval("\$ficon .= \"".$templates->get("ficon_index")."\";");
No, It doesn't work
http://docs.mybb.com/1.8/development/plugins/hooks/
As you can see, $forum should be passed as a function parameter, not globalized.

And concatenation isn't needed there because it's an conditional with a single assignment, not a loop.