XF 1.3 BB Code not working :s

MichaelDance

Well-known member
I'm trying to do a BBCode which only shows to Admins and Moderators but for some reason this BB Code shows to everyone. Confused me.

xenforobbcode.webp

What shows when a user isn't logged in or a non Moderator / Administrator:

Logout.webp
---
I've tried following: http://xenforo.com/community/thread...b-code-in-xenforo-a-comprehensive-guide.6320/

PHP:
<?php

class MODRelease_EventListener_MODRelease
{
    public static function listen($class, array &$extend)
    {
        if ($class == 'XenForo_MODRelease_Formatter_Base')
        {
            $extend[] = 'MODRelease_MODRelease_Formatter_Base';
        }
    }
}

PHP:
class MODRelease_MODRelease_Formatter_Base extends XFCP_MODRelease_MODRelease_Formatter_Base
{
    protected $_tags;
    public function getTags()
    {
        $this->_tags = parent::getTags();
        $this->_tags['modreserve'] = array(
            'hasOption' => false,
            'replace' => array('<i style="color:red;"><b>A reserve has been set by the seller.</b></i><br /><xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}"><p>Reserve Price: <b>', '</b></p>')
        );
        return $this->_tags;
    }
}

Thank you for your help.
 
Last edited:
Template syntax doesn't work there. If you view the source code of the page you will notice that the conditional is present in the source. It shows raw, like this:

Code:
<xen:if is="{$visitor.is_admin}">...</xen:if>

The browser doesn't render it but it's there which shows that XenForo doesn't parse template syntax in BB code replacements.

This is possible with an addon, but that then becomes a development question.
 
Template syntax doesn't work there. If you view the source code of the page you will notice that the conditional is present in the source. It shows raw, like this:

Code:
<xen:if is="{$visitor.is_admin}">...</xen:if>

The browser doesn't render it but it's there which shows that XenForo doesn't parse template syntax in BB code replacements.

This is possible with an addon, but that then becomes a development question.

Oh dam haha was hoping it wouldn't be that. Thank you mate.
 
I saw your other thread, but you might find this quite simple.

I would recommend using the Custom BB Code system included in XenForo 1.3 and set up a PHP callback for your BB Code. Here's a very simple template of how that could work:

PHP:
<?php

class YourAddOn_BbCode_YourCallback
{
    public static function tagYourBbCode(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {
        $view = $formatter->getView();
        if ($view)
        {
            $viewParams = array();

            $template = $view->createTemplateObject('your_template_name', $viewParams);
           
            return $template->render();
        }
        else
        {
            return $formatter->renderTagUnparsed($tag, $rendererStates);
        }
    }
}

The key point to note is that under normal conditions this can return a standard template. In that template you can use the XenForo template syntax as you were attempting to do.
 
I saw your other thread, but you might find this quite simple.

I would recommend using the Custom BB Code system included in XenForo 1.3 and set up a PHP callback for your BB Code. Here's a very simple template of how that could work:

PHP:
<?php

class YourAddOn_BbCode_YourCallback
{
    public static function tagYourBbCode(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {
        $view = $formatter->getView();
        if ($view)
        {
            $viewParams = array();

            $template = $view->createTemplateObject('your_template_name', $viewParams);
          
            return $template->render();
        }
        else
        {
            return $formatter->renderTagUnparsed($tag, $rendererStates);
        }
    }
}

The key point to note is that under normal conditions this can return a standard template. In that template you can use the XenForo template syntax as you were attempting to do.

Thank you mate I tried doing that and I got the tag sort of working it vanishes so I think I need to learn a bit more before I do anything haha.
 
Back
Top Bottom