1
ショートコードをWYSIWYGに追加しようとしています。私はthis libraryを使用しています。私はaccordion from bootstrapにこれを解析しようとしています:thunderer/shortcodeを使用してショートコードを解析しようとしています
[panel]
[header]
Heading goes here
[/header]
[content] Content goes here [/content]
[header]
Heading goes here
[/header]
[content] Content goes here [/content]
[/panel]
私のコードは次のようになります。
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);
私の問題は、今私が解析しようとしているとき、それは開始タグを解析することであるが、終了タグではないので、getContent()が機能しないという理由で想像しています。どのようなアイデアを私は間違って何ですか?ありがとう
驚くばかりの図書館の男! – raygo