Kirby Modules Plugin returns null

Hi!

I have been trying to install the Kirby Modules Plugin and followed the instructions from https://github.com/getkirby-plugins/modules-plugin/blob/master/readme.md but when I test it on the default template, nothing prints out. When I var_dump $page->module() it returns null. Not the module object.

I’m using the plugin’s demo content (gallery and text).

In the panel everything seems to work fine. I can create subpages with the module templates (text module and gallery module) and the modules content files are in the content folder after I hit the save button.

What have I missed or done wrong?

What is the subpages status? I think they must be visible.

I’ll check the subpages status tomorrow. Thank you for the tip.

You can’t use $page->module() from the default template. It’s intended use is to get the internal module object for a module page.

You probably meant to use $page->modules().

Yes, I meant $page->modules(). I’m pretty sure it was what I used. I’ll check it tomorrow when I have my computer around.

@lukasbestle can you confirm that the subpages must be visible to work? Thanks for the help!

Yes, otherwise you wouldn’t be able to sort the modules. Making modules invisible is also a feature to allow editors to prepare a module before publishing it.

I changed the subpages to visible and now everything works fine. Thanks @pedroborges and @lukasbestle for the help and your quick answers!

1 Like