Myck
Member
Hello I am trying to create a bbcode with several options but this for me is very complicated, I have already reviewed all the posts in the forum and I managed to complete a code that does not work for me, please help me to finish it, it could help me by checking where I am failing.
When creating the bbcode I also used the PHP callback and created a file called BbcodeParser.php in the path MyAddon / Bbcode /, in short I followed all the steps to create a bb code with callback, but when I use the code bb in a thread does not work.
BBcode label
PHP callback
When creating the bbcode I also used the PHP callback and created a file called BbcodeParser.php in the path MyAddon / Bbcode /, in short I followed all the steps to create a bb code with callback, but when I use the code bb in a thread does not work.
BBcode label
Code:
[mp3 = {text2}, {text3}] {text} [/ mp3]
It would look like this:
[mp3 = 1, Sample text] URL text [/ mp3]
PHP callback
Code:
<?php
namespace MyAddon\Bbcode;
class BbcodeParser {
public static function mp3($tagChildren, $tagOption, $tag, array $options, \XF\BbCode\Renderer\AbstractRenderer $renderer)
{
$res = $renderer->renderSubTree($tagChildren, $options);
$toptions = trim(strip_tags($tag['option']));
$toptions = preg_split("|,|", $toptions, -1, PREG_SPLIT_NO_EMPTY);
// [mp3={text2},{text3}]{text}[/mp3]
@list($text2, $text3) = $toptions;
if ($tmp = trim($text2)) {
$two = "$tmp";
}
if ($tmp = trim($text3)) {
$three = "$tmp";
}
return "<mp3 {$two} {$three}>{$res}</mp3>";
}
}