XF 2.1 Porting TOC BB code add-on for XF2.1

Slion

Active member
I'm trying to port an add-on I developed 3 years ago for XF1.5 to XF2.1.
Here is the original thread about it:

I don't think it's storing any data in the database. It is just parsing and rendering a bunch of BB codes really.
So I'm guessing I don't need a setup.

I ran xf-addon:create and told it to supersede an XF1 add-on. Now when looking at the CP it looks like that add-on is enabled but still listed as legacy.
I'm not sure what's the next step TBH.

1584647280519.webp

Is there a guide on how to port such a BB code add-on from XF1 to XF2?
 
Went in the database and changed that is_legacy flag for that add-on in xf_addon table. Not sure I'm supposed to do that though.
 
With Class extension I tried something like that:
PHP:
<?php

namespace Slions\Toc\XF\BbCode\Renderer;

class Html extends XFCP_Html
{

    public function addDefaultTags()
    {
        // This is an override so we need to call the parent function to preserve stock behaviour
        parent::addDefaultTags();
       
        // Add our new BbCode tags
        $this->addTag('h1', ['replace' => ['<h1>', '</h1>']]);
        $this->addTag('h2', ['replace' => ['<h2>', '</h2>']]);
        $this->addTag('h3', ['replace' => ['<h3>', '</h3>']]);
        $this->addTag('h4', ['replace' => ['<h4>', '</h4>']]);
        $this->addTag('h5', ['replace' => ['<h5>', '</h5>']]);
        $this->addTag('h6', ['replace' => ['<h6>', '</h6>']]);
    }
}

However for some reason it is not working as I would expect.
If I don't call the parent implementation it breaks all built-in BbCodes so that override is working.
However those H tag won't work for some reason.

I guess I have to use that Custom BbCode thing instead.
 
Last edited:
I got the basics working using those custom bbcode callbacks.
Though I'm not sure how to render them in the editor.
 
 
Back
Top Bottom