Kirby Modules Plugin


Say I’m building a submenu, where each item is a kirby-module, how would I access the title field of each module?

So far I can use modules(), modulesList() and other helpers, but the best I reached was to get to the module object and output it as a string unfortunately.

My code is

<?php $sections = $pages->filterBy('template', 'section'); ?>
  <?php foreach($sections as $sec): ?>
    <?= $sec->?? ?>
<?php endforeach ?>

I tried to get to the module page using ->grandChildren but without good results.

The example of printing single modules worked, but I need to only access a specific field for all pages meeting the criterias above.



I don’t quite understand what you are trying to fetch here. All modules of all main pages? Could you post an outline of your structure?

A module is a standard page. So if we assume that a project page in a Starterkit had some module grandchildren:

- /project-a
        module- text.txt

The you would get the modules like this:

$sections = $page->grandChildren()->visible();
foreach($sections as $section):
  echo $section->title();


Thank you!

Using ->grandChildren() was giving me null, so I’m using ->children() twice like so

<?php $sections = $pages->filterBy('template', 'section')->children() ?>

<?php foreach($sections->children() as $sec): ?>
    <?= $sec->title() ?>
<?php endforeach ?>


19 posts were split to a new topic: Modules plugin: Print all modules from all visible pages