Clearleft/Clearright/Clearboth self-closing tags.

Vekseid

New Member
Reactions
4
You don't seem to have a prefix for this one.

Anyway, on my forums I have floatleft and floatright tags, generally with an option for padding. Making self-closing clear tags is easy enough on SMF/Elkarte but I need to make an addon for this in Xenforo, obviously.

It's a minor thing but it's the difference between doing this myself (and making what I need on my own) or buying your addon. : )

Thanks.
 
The add-on actually add's support for self-closing tags to the bb-code parser, but isn't exposed to the admin UI & add-on import/export stuff.

If you have this add-on, and then extend the event bb_code_rules, and have something like this;
PHP:
    public static function bbCodeRules(\XF\BbCode\RuleSet $ruleSet, $context, $subContext)
    {
        // heading tags
        $ruleSet->modifyTag('hr', [
            'selfClosing' => true
        ]);
   }

Then [hr] will be self-closing, and you can adjust any other tag you want.

I'm not going to have the time to add the UI bits for a while.
 
Is this supposed to be right? I've got:

1567140376353.png


and

Code:
<?php

namespace Vekseid\CloseTags;

class CloseTags {

    public static function bbCodeRules(\XF\BbCode\RuleSet $ruleSet, $context, $subContext)
    {
        // heading tags
        $ruleSet->modifyTag('hr', [
            'selfClosing' => true
        ]);
        $ruleSet->modifyTag('clearleft', [
            'selfClosing' => true
        ]);
        $ruleSet->modifyTag('clearright', [
            'selfClosing' => true
        ]);
        $ruleSet->modifyTag('clearboth', [
            'selfClosing' => true
        ]);
    }
}

But this isn't working for the clear tags in my test forum.
 
It needs to be a code event listeners (with development mode enabled);
1567147342136.png


That is you'ld want to make a mini-addon to bundle the code + config together
 
That was a different error - it seemed to only occur on posting. And your hr tag is working fine as you already declare it self closing in your listener. I don't think it can be the execution order as yours is running after this (unless XenForo is lying to me about lower numbers being executed first) and the function is just an array merge.

It is calling your code, but it doesn't recognize that selfclosing has been set.

So I'm a bit at a loss.
 
Moved this to that ticket you've recently opened, since I've got some questions.

The order shouldn't matter, only thing I can think of is the tag names aren't matching 100% properly
 

Users who are viewing this thread

Back
Top