Creating a Custom BB Code in XenForo: A Comprehensive Guide

@Jeremy or others

I think I've ascertained that I did exactly the same with this guide but was still getting this error:
_tags = parent::getTags(); $this->_tags['h2'] = array( 'hasOption' => false, 'replace' => array('
', '

') ); $this->_tags['float'] = array( 'hasOption' => true, 'replace' => array('
', '
') ); return $this->_tags; } }_tags = parent::getTags(); $this->_tags['h2'] = array( 'hasOption' => false, 'replace' => array('
', '

') ); $this->_tags['float'] = array( 'hasOption' => true, 'replace' => array('
', '
') ); return $this->_tags; } }
Fatal error: Class 'XenBBCode_BbCode_Formatter_Base' not found in C:\xampp\htdocs\community\library\XenForo\BbCode\Formatter\Base.php on line 1912

I'm using XF 1.3.3 . Any help, please ? Thanks :)
 
If you receive that error, you likely didn't upload your class to the correct location or named it improperly.
 
Code:
<?php

<?php

class idwsTable_BbCode_Formatter_Base extends XFCP_idwsTable_BbCode_Formatter_Base
{
    protected $_tags;
    public function getTags()
    {
        $this->_tags = parent::getTags();
        $this->_tags['idwstable'] = array(
            'hasOption' => true,
            'replace' => array('<table style="background-color: %s;>', '</table>')
        );
       $this->_tags['idwstr'] = array(
            'hasOption' => true,
            'replace' => array('<tr style="background-color: %s;>', '</tr>')
        );
    $this->_tags['idwstd'] = array(
            'hasOption' => true,
            'replace' => array('<td style="background-color: %s;>', '</td>')
        );
        $this->_tags['idwstdcolspan'] = array(
                'parseCallback' => array($this, 'parseValidatePlainIfNoOption'),
                'callback' => array($this, 'renderTagColspan')
            );
                       
                   
        return $this->_tags;
    }
 
    public function renderTagColspan(array $tag, array $rendererStates)
    {
        if($tag['option'] != NULL)
        {
            $jumlahcolspan = $tag['option'];
        }
        else
        {
            $jumlahcolspan = '2';
        }
        $output = '<td colspan="' . $jumlahcolspan . '"> ' . $tag['children'][0] . ' </td>';
     
        return $output;
    }
}

[idwstable][idwstr="skyblue"]
[idwstdcolspan="3"] judul dengan 3 colspan[/idwstd]
[/idwstr]
[idwstr]
[idwstd]1[/idwstd]
[idwstd]2[/idwstd]
[idwstd]3[/idwstd]
[/idwstr]
[/idwstable]

not working, where am I wrong ?

and also just quick question, the code also can intertupted with css if you put [idwstable=red;evil_css_here;] how to sanitize that ?
 
Last edited:
Back
Top Bottom