problem with hook
#1
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?
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#2
Instead of

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

Try this

eval("\$ficon .= \"".$templates->get("ficon_index")."\";");
Reply
#3
No, It doesn't work
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#4
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)