Good questions @texnixe
Did some tests with div
tags in accordion snippet placed so it breaks the layout:
- Disabled all plugins (got a few ;-): no change
- Text field only with accordion tag: no change
- Cleared config completely: bingo fixed
Cleared config bit by bit and the culprit seems to be:
'markdown' => [
'extra' => true,
],
When I set Markdown Extra to false
it works properly.
Side note: tables still render properly when Markdown Extra is disabled, which is supposed to be a Markdown Extra feature according to the Kirby ref. Just checked https://parsedown.org/demo and the tables are indeed part of ‘regular’ Parsedown (right?).
Can we say that this is a Parse Down Extra problem, can you reproduce?
My bits and pieces:
blueprint:
accordion:
label: Accordion
type: structure
help: Write text and place the accordion tag; accordion between double curly braces, anywhere in the Text field.
fields:
accordion_open:
label: Open
type: toggle
accordion_heading:
label: Header
type: text
accordion_content:
label: Panel
type: textarea
buttons:
- italic
- bold
- link
- email
- code
- ul
- ol
accordion_multiple:
label: Single panel open
type: toggle
width: 1/2
accordion_heading:
default: 'h3'
label: Accordion header
type: select
width: 1/2
placeholder: Select a heading type
options:
- value: 'h2'
text: Heading 2
- value: 'h3'
text: Heading 3
- value: 'h4'
text: Heading 4
- value: 'h5'
text: Heading 5
- value: 'h6'
text: Heading 6
plugin:
<?php
Kirby::plugin('zoon/accordion', [
'hooks' => [
'kirbytags:after' => function ($text, $data) {
return preg_replace_callback('!{{ accordion }}!siU', function($match) use ($data) {
if ($items = $data['parent']->accordion()->toStructure()) {
$block = snippet('accordion', ['items' => $items], true);
} else {
$block = '';
}
return $block;
}, $text);
}
]
]);
snippet:
<?php if($items->count()): ?>
<div class="js-accordion" data-accordion-prefix-classes="animated-accordion" <?= e($page->accordion_multiple()->bool(), 'data-accordion-multiselectable="none"', '') ?>>
<?php $n=0; foreach ($items as $item): $n++; ?>
<div class="js-accordion__panel" <?= e($item->accordion_open()->bool(), 'data-accordion-opened="true"', '') ?>>
<?php if($page->accordion_heading()->isNotEmpty()): ?>
<?= '<' . $page->accordion_heading()->value() . ' class="js-accordion__header">'?>
<?= smartypants($item->accordion_heading()) ?>
<?= '</' . $page->accordion_heading()->value() . '>' ?>
<?php else: ?>
<h3 class="js-accordion__header">
<?= smartypants($item->accordion_heading()) ?>
</h3>
<?php endif ?>
<div class="js-accordion__content">
<?= $item->accordion_content()->kt() ?></div>
</div>
<?php endforeach ?>
</div>
<?php endif ?>
… and this code for selecting a heading type (h2–h6) doesn’t work full stop, but I can try different ways:
<?php if($page->accordion_heading()->isNotEmpty()): ?>
<?= '<' . $page->accordion_heading()->value() . ' class="js-accordion__header">'?>
<?= smartypants($item->accordion_heading()) ?>
<?= '</' . $page->accordion_heading()->value() . '>' ?>
<?php else: ?>
…
(Just installed Kirby Editor, would be better for UX to put an accordion into a block, also multiple accordions. But have to spend time to learn to code custom blocks first.)