The WordPress plugin Advanced custom fields has a really nice feature called _Conditional logic_. Essentially, what this does is it lets the theme developer specify a condition under which fields should be shown/hidden. This is really powerful when you have a list field where the different entries can be of different types (eg. text/image). When the content author specifies that an entry has the image type, I might want to show a pagemediaselect control, and when it's a text entry, I might want to show a textarea.
Implementation-wise, this should only be a front-end concern for the admin panel. As for how to configure it, a common blueprint field property that specifies a target field and a desired value should hopefully be enough.
I'm not sure how this would work. How does the author indicate that it's an image type layout? from another select box?
With Grav, the intention is the designer provides page templates for each page type he/she has a unique design for. Alternatively the designer could provide modular templates to provide in page modular elements that can be used to build a page.
Either way, these each have their own blueprint that can provide any fields the user needs.
Yep, the idea was that I'd use a toggle or a check box to control the entry's type. I tried to adapt my use case to the modular page logic, but I'm not sure it such a good fit. Let me paint the picture of what I'm trying to do and why I think a feature like this would be a good fit for cases like mine:
I have a page consisting of a curated set of images in different widths (50% or 25% of the page). Each image is part of a group, where the group specifies mostly just metadata (like what page the images link to).
Every entry can also be either a text entry or a breakpoint. Text entries just show some text instead of an image. Breakpoints specify points along the Y axis of the page where the user has to click a "Show more" link in order to show more posts.
The layout of the main page depends on data from the image entries. For example, I infer the places where a grid row should be rendered by counting the widths of the images that I loop over (50+50=100 or 25+25+50=100 and so on).
Also, being able to easily reorder the list entries is important, so the solution I've used so far with a list control has suited me well.
So, the problem right now is basically just that I don't want to show all the image related controls when the list entry is in fact a breakpoint or a text entry, and so on. I do want to embrace Grav's logic, but I really think a feature like this would complement the modular page logic for even more atomic page components.
Yes please!
I have a module that videos and images can take up the same slots, but there are some options that don't make sense to show like Loop? (Y/N).
I think this can have even more usage scenarios if we implement sets of options that depend on other options.
In @krispy1298 example, a list could have a main field type which is called type, which has 2 values: video and image.
Next, in the blueprint, we have 2 sets. One that shows if type == video and the other that shows if type == image.
This can be used in other blueprints too, not just lists, even in the System configuration to only show some options if needed (e.g. show cache options only if cache is enabled).
Would it be possible to generate blueprints from a twig template? If so, it would be easy to add forms based on whether images/videos/etc were present, and even allow for generating form elements based on the collection each object belongs to.
Would it be possible to generate blueprints from a twig template?
Not at this point
Most helpful comment
I think this can have even more usage scenarios if we implement sets of options that depend on other options.
In @krispy1298 example, a list could have a main field type which is called
type, which has 2 values: video and image.Next, in the blueprint, we have 2 sets. One that shows if type == video and the other that shows if type == image.
This can be used in other blueprints too, not just lists, even in the System configuration to only show some options if needed (e.g. show cache options only if cache is enabled).