I would like to create a BB Code called "Hide"

AndyB

Well-known member
Hello,

I would like to create a Custom BB Code called "Hide". The purpose of this BB Code is to allow a member to enter into a post some text that will be hidden to all except the author and those with permissions to view this hidden text. For example the member would enter a BB Code like this:

Code:
[hide]This text is hidden[/hide]

and only the author of the post and those with the appropriate permissions can view it. For example Moderators and the Administration groups would be able to always see this hidden text contained in the "Hide" BB Code.
 
Last edited:
I have created the following file:

Andy/Hide/BbCode/Hide.php

PHP:
<?php

class Andy_Hide_BbCode_Hide
{
    public static function render(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {
        $view = $formatter->getView();
        if ($view)
        {
			
			$var = 'got here';
			
            $template = $view->createTemplateObject('andy_hide', array(
				'var' => $var
			));

            return $template->render();
        }	
	}
}
 
Last edited:
At this point the andy_hide template is returned properly. So if I enter the following BB Code into a post:

Code:
[hide]This text is hidden[/hide]

The words "got here" is put in place of the BB Code.
 
Last edited:
Well I just realized this won't work because if the post is quoted the text will be shown.

However I this thread will be useful to anyone wondering how to use the PHP Callback in BB Codes.
 
Top Bottom