Hey there again,
so I got this accordion-plugin working on my site.
Now I create a page, which displays the content and add a subpage with the accordion template, that only contains the accordions. Then I’m trying to make different subpages for different sets of accordions and to let those be shown on the page in different sections.
-job offer 1 with job infos
-job offer 2 with job infos
and so on
and so on
Here’s the code for the accordion.php:
< section class="section-text"> <?php foreach($page->children()->visible() as $child): ?> <h2><?= $child->title()->html() ?></h2> <?php endforeach ?> <?php $accordions = $module->accordions()->yaml() ?> <?php $first = a::first($accordions) ?> <?php foreach($accordions as $accordion): ?> <label class="accordion"> <input type='<?php echo html($module->accordiontype()) ?>' name='<?php echo html($module->accordiontype()) ?>-accordion' <?php if($accordion == $first) echo ' checked="checked"' ?>> <div class="accordion__header"><?php echo $accordion['header'] ?></div> <div class="accordion__content"> <p><?php echo kirbytext($accordion['content_short']) ?></p> <?php $filename = $accordion['content_pdf']; if ($pdf = $module->files()->get($filename)): ?> <h6>Download PDF:</h6> <a href="<?php echo $pdf->url() ?>" style="text-decoration:underline">PDF-File (<?php echo $pdf->niceSize() ?>)</a> <?php endif; ?> </div> </label> <?php endforeach ?>
I know the first part shows all the titles of all the subpages at once on top of each accordion-section. If I put the endforeach at the end, it shows both subpages twice with one of the titles over each accordion-section.
So here’s my question: how do I get only the proper title for the right subpage to show on the page? I tried a few different things I found on the forums but it either shows both titles on top of both sections or it doesn’t show anyting at all…
Any help is greatly appreciated.