Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get custom bbcode tag content #203

Closed
Nearata opened this issue Sep 5, 2022 · 5 comments
Closed

Get custom bbcode tag content #203

Nearata opened this issue Sep 5, 2022 · 5 comments

Comments

@Nearata
Copy link

Nearata commented Sep 5, 2022

at the moment im using useContent to get the content between the brackets

'[custom content="{ANYTHING;useContent}"]{ANYTHING}[/custom]',
'<div class="custom-bbcode">{ANYTHING}</div>'

but 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.

@JoshyPHP
Copy link
Member

JoshyPHP commented Sep 5, 2022

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.

@Nearata
Copy link
Author

Nearata commented Sep 6, 2022

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.

@JoshyPHP
Copy link
Member

JoshyPHP commented Sep 6, 2022

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/

@Nearata
Copy link
Author

Nearata commented Sep 6, 2022

rethinking about it, the purpose of this bbcode has nothing to do with this library.

Sorry if i wasted your time.

@Nearata Nearata closed this as completed Sep 6, 2022
@JoshyPHP
Copy link
Member

JoshyPHP commented Sep 6, 2022

Not at all. Let me know if you need anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants