Creating module with subpage builder


#1

I’ve been having an issue with using subpage builder to build a specific module. Imagine I have a module called ‘test’, with the module template ‘module.test’. To create a new module using Subpage Builder, I would do this:

build:
        - title: Test
        uid: modules/test
        template: module.test

This works, however, you end up with a nasty error and not allowing you to continue. If you reload the page, the page and the module are created nonetheless.

I’ve been using Modules Builder to take care of building the Modules for specific modules. It probably has something to do with the fact that maybe the route it addresses gets executed after Kirby tries building the subpage? Anyone with experience building this?


#2

I. think the problem here is that you add a path where you should just have a UID


#3

The reason why it’s there is because otherwise the module subpage would be placed in the root of the page folder, not the ‘modules’ folder.

I’ve been trying to operate it through a hook, but haven’t had any luck with that one yet.


#4

Well, it is not indended to work like that. You would need one blueprint that creates the modules folder (the page blueprint), and then for the module subpage a blueprint that creates the submodule pages.

So this:

build:
        - title: Test
        uid: test
        template: module.test

would go into modules.yml


#5

It kinda works because there’s a hook creating the modules subfolder, before (?) the subpage builder gets initiated. It’s only the panel that’s not up to speed of what’s happening in the background (hence the error).

Having to put it ‘the right way’ would mean the modularity of the modules concept goes lost. I could just put in a few modules in any blueprint and let the panel create them in the background.


#6

I’m just telling you how it is supposed to work.

I see your point. What you can do:

  • for each type of page that needs different modules, give those modules subpages another blueprint. Then in that modules_type1.yml define what modules should be created.
  • put the modules directly into the page folder without the modules subpage
  • try to modify the Panel source code

#7

I get that! I’m happy that it works in most cases. Because most modules in this project are either interfaces for functions or snippets, I’ll solve it in another way.

Thanks for thinking with me tho.


#8

Oh, yeah, and I forgot the hooks, of course. But you said that didn’t work out for you?