Closed shoogstoel closed 3 years ago
Yes this would be very helpful to me as well - especially when i want to use modules for "slots" on page like Header/Footer quite powerful pattern i've discovered recently. I've been trying it out and Pages section that modules uses cannot filter pages with query. It can either set parent or filter with template. Both have problems...
Setting parent would require having multiple modules root pages and i am sure we all want the clean page>modules>all-my-modules
folder structure. Also lot of the internals expect this so having page>modules-a>my-a-modules
and page>modules-b>my-b-modules
wouldn't cut it.
Using templates filter would probably work right now already but it's dumb because you would have to use different templates for each Modules section for this to work correctly. It might work in some rare occasions but not in general.
The best approach how to do this seem to me would be to create holding "subpages" for the modules inside the modules folder like page>modules>a-modules>my-a-modules
and page>modules>b-modules>my-b-modules
. Now i am not sure how this would conflict with overall logic of modules but maybe it could even work along side normal "default" modules if it's filtered out properly.
I don't have time right now but i will want this in upcoming 3 months so i might have a go at this at some point.
I like this idea. Some things to keep in mind:
->modules()
method will have to accept a parameter or so to differentiate between the different module containers.Very good points guys. My use case is quite simple and makes it a lot easier. I never have more than 1 modules section on a single page.
To give an example: Let's say you have a page blueprint called legal
which only allows simple text and image modules to be used. The default
page template's module section allows all modules to be used. For that rather simple use case, a change along the following would work just fine:
'templates' => function($templates = null) use (&$blueprints) {
return $templates !== null ? Yaml::decode($templates) : $blueprints;
},
But, as I said, I really didn't think of your use case @iskrisis
@shoogstoel Then your use case is already possible.
# site/blueprints/pages/default.yml
sections:
modules: true
# site/blueprints/pages/legal.yml
sections:
modules:
create:
- module.text
- module.image
You're right. I was using an old (very old I'm afraid) version of your plugin.
I regularly find myself in the situation where I need 2 sets of modules sections, each with a specific set of allowed modules. Any chance this could be added?