WYSIWYG'ye kısa kodları eklemeye çalışıyorum. this library kullanıyorum. Bir accordion from bootstrap içine bu ayrıştırmak çalışıyorum:Thunderer/shortcode kullanarak bir kısa kod ayrıştırmaya çalışılıyor
[panel]
[header]
Heading goes here
[/header]
[content] Content goes here [/content]
[header]
Heading goes here
[/header]
[content] Content goes here [/content]
[/panel]
Benim kod şuna benzer:
use Thunder\Shortcode\HandlerContainer\HandlerContainer;
use Thunder\Shortcode\Parser\RegularParser;
use Thunder\Shortcode\Processor\Processor;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
function processAgendaContent($content)
{
$handlers = new HandlerContainer();
$handlers->add('panel', function(ShortcodeInterface $s) {
return "<div class=\"panel panel-default\">";
});
$handlers->add('header', function(ShortcodeInterface $s) {
return '
<h4 class="panel-title">
<a href="#collapse1" target="_blank" role="button" data-toggle="collapse" aria-expanded="true" aria-controls="collapse1" class="btn-collapse">
' . $s->getContent() . '</a>
</h4>';
});
$processor = new Processor(new RegularParser(), $handlers);
echo $processor->process($content);
Sorunum şu anda ayrıştırmak çalışıyorum, bunun açılış etiketini ayrıştırır olmasıdır ama kapanış etiketi değil ve bu nedenle getContent() işlevinin çalışmadığını hayal ediyorum. Herhangi bir fikrim yanlış ne yapıyorum? Teşekkürler
Harika kütüphane adam! – raygo