XF 1.4 Possible with BBCode?

Rob

Well-known member
Our site has quizzes, Q&A sessions, senario based learning and revision sessions. These sessions are sponsored by different companies and need some kind of attribution in each "first post". The problem is the attribution formatting, links and colours wildly differ depending on who is posting. I'd like to provide staff a special bbcode which will automatically insert the attribution content.

I'd like to set up a bbcode like this:-

[sponsor="company"][/sponsor]

The content to replace the above would depend on the company defined in the parameter. For instance:-
[sponsor="ibm"][/sponsor] and [sponsor="microsoft"][/sponsor]
.....would render entirely different content.

Is this possible at all without using callbacks? How would this be set up?

Thanks for any help and direction.

Thanks,
Rob
 
If the only dependency is what you render based on the "option" of the BB code, then you could do that with a callback. It would just switch it's behavior based on what's passed. You would need to write custom PHP code in the callback to read the option and switch on the various cases.

If you're only wanting it to render based on the person who owns the post, that's more difficult as the user isn't directly exposed to the parser.
 
I want the callback to grab the content from a template so I can just extend the sponsors by adding a template prefixed with bbSponsor_
I know the following wont work, but you should be able to work out what I want to do.
My isssue is that there is not a template object I can use and I don't know specifically how to call it and make it parse the bbcode and have it correctly deal with the content as it leaves the callback. :S

Not sure if this is even possible but hopefully it is.

PHP:
<?php
class BbcodeSponsor_Callback
{
    public static function render(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {
        $view = $formatter->getView();
        $params = array ();

        if ($view)
        {
            $template = $view->__construct($view->getRenderer, $view->getResponse, $params, 'bbSponsor_' . strtolower($tag['children'][0]));
            if ($template) {
                return $template->render();
            } else {
                return "Template Does Not Exist";
            }
        }
    }
}
 
You can take a look at the Bbm. You create the Bb Code, you link it to a template. In the template, you check in a conditional the Bb Code option (check to demo Bb Code provided with them, especially the HL one). According to the option caught you reroute them to an another template using the default xen tags (include).
 
I don't really need a complex, full blown bbcode manager mod for this as it's overkill imo as I only need this one function, but thank you anyway.
I'd sooner use the bbcode callback than a hook if possible.

I can't seem to create a new template object from within the bbcode callback.
$template = new XenForo_Template_Abstract;
The above line fails dismally.
 
Last edited:
I don't really need a complex, full blown bbcode manager mod for this as it's overkill imo as I only need this one function, but thank you anyway.
I'd sooner use the bbcode callback than a hook if possible.

I can't seem to create a new template object from within the bbcode callback.
$template = new XenForo_Template_Abstract;
The above line fails dismally.
Up to you, then check the function 'renderBbmTemplate' from this file. Note that you will have to cache the template to avoid extra request and every of your members will be able to use this Bb Code (not only your staff).
 
Hmmm.... permissions, now there's something I've not thought of. Also, I don't want the bbcode to appear in help pages. I presume the bbm has permissions sorted and allows secret bbcodes?
 
Back
Top Bottom