Closed Nearata closed 2 years ago
It depends on whether you're more interested in "easy" or "correct". For the former, you can load the XML in a DOMDocument and perform your alterations using DOM operations. For the latter, if you describe your use case there is probably a better way to achieve the same result.
i'd like to edit the bbcode output based on its attributes value
'[custom attr1="{TEXT}" attr2="{TEXT1}" content="{ANYTHING;useContent}"]{ANYTHING}[/custom]',
'<div class="custom-bbcode">{ANYTHING}</div>'
return Utils::replaceAttributes($xml, $tag, function ($attrs) {
if ($attrs['attr1'] === 'pog') {
$attrs['content'] = 'PogU';
}
return $attrs;
});
the above code works as expected, but the output (content attribute) is rendered as plain text instead of html.
But what is the purpose of that BBCode? If you want custom emoticons, you can use the Emoticons plugin. They are parsed at parsing (or posting) time though.
https://s9etextformatter.readthedocs.io/Plugins/Emoticons/Add_emoticons/
rethinking about it, the purpose of this bbcode has nothing to do with this library.
Sorry if i wasted your time.
Not at all. Let me know if you need anything else.
at the moment im using
useContent
to get the content between the bracketsbut with this the inner content is rendered as plain text.
the goal is to replace the content of the bbcode dynamically with
Utils::replaceAttributes()
.is there an easy way to achieve this? i'm using Flarum 1.4.1.