Hi there…
I’m busily learning all I can about Kirby but I have a question from the end users that I’m not sure how to solve.
We’re using the modules plugin and are wondering if we can use a module with a module to solve the following?
We have a module that generates an accordion, complete with a header. We’d like to make the number of items in the accordion dynamic so that users can add additional subheaders and lines to the accordion.
Our module looks like this at present:
<section class="o-accordion">
<div class="container">
<?php pattern( '01-atoms/typography/heading-two', [ 'text' => kirbytext($module->heading()) ] ) ?>
<?php pattern( '02-molecules/accordion', [
'subheading1' => kirbytext($module->subheading1()),
'content1' => kirbytext($module->content1()),
'subheading2' => kirbytext($module->subheading2()),
'content2' => kirbytext($module->content2()),
'subheading3' => kirbytext($module->subheading3()),
'content3' => kirbytext($module->content3()),
] ) ?>
</div>
</section>
Our blueprint looks like this:
title: Accordion Module
pages: false
files: false
fields:
heading:
label: Accordion heading
type: text
subheading1:
label: Heading for the first accordion
type: text
content1:
label: Text for first accordion
type: textarea
subheading2:
label: Heading for the second accordion
type: text
content2:
label: Text for the second accordion
type: textarea
subheading3:
label: Heading for the third accordion
type: text
content3:
label: Text for the third accordion
type: textarea
We’d like to make subheadingX and contentX be variable.
I tried adding a module to the module blueprint, but I couldn’t get it to work.
- So my questions are, can modules have submodules?
- Is that the way to solve this problem?
- Any other idea of how to solve this?
I thank you all in advance.