XF 2.0 Help with simple custom bbcode callback

jyncka

New member
I'm hoping someone can lend me a second set of eyes on this because I can't see what's wrong. I am trying to learn how to make callbacks for custom bbcodes and have this class:

PHP:
class MyAddOn_BbCode_Image {
    public static function img2(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {
        $options = explode($tag, ',');
        return "<img src=' . $tag["children"][0] . '" style='height: " . $options[0] . "px; width: " . $options[1] . "px;' >";
    }
}

And in my ACP I have set the custom code to "php callback" and then entered this in the class::method fields:
Code:
MyAddOn\BbCode\Image::img2
The class is installed in library/MyAddOn/BbCode/Image.php but when I try to save I get this: "Callback MyAddOn\BbCode\Image::img2 is invalid (error_invalid_class).".

Where am I going wrong?
 
XF 2, I've found some discussion threads but I don't know if something major changed in XF2 that I'm unaware of.
 
Yea, well, everything regarding your path and class name.
Addons are placed into /src/addons/{your}/{structure}/{class.php}.
The class name is obviously the file name (generally) and not the path anymore.
Vice versa the path is not the class name anymore, but {your}/{structure}/{class}
 
Back
Top Bottom