generatepress icon indicating copy to clipboard operation
generatepress copied to clipboard

Elements - plans for additional display conditons

Open eastriverstudio opened this issue 3 years ago • 4 comments

I'm wondering if there are any plans to introduce some updates to GPP element's display conditions? The current set is pretty flexibile but there are some obvious omissions which I think could be welcome.

The first and most needed I feel is a 'child of' condition, so for hierarchial structures such as pages we can specify a parent to target all children underneath. This would be useful for a lot of applications, such as for example having a content template for a specific set of children under somehting like a service page. We have the 'child of' condition in GBP query loop now, hopefully this is also possible in GPP in a similar way?

A second would be a related condition. I think this would dovetail nicely off of the new related params recently added to GBP and would allow the showing of an element if related to a condition in the current post. So an obvious application I can think of related to the query loop would be showing a block element only if there are more posts with a related taxonomy.

thirdly, I think post meta would also be a helpful condition to have in Elements. So similar to how the post meta selection works in GBP blocks, we can specify some post meta, which if it has a value we can show an element. There would potentially be a lot of applications for this, but an example one would be we could use a tool like ACF to create fields for the admin user so they could show or hide elements in a template dependent on post meta values.

I would be interest to hear your thoughts on these and if there are any plans in the pipeline for additions to the display conditions.

Thanks

eastriverstudio avatar Jul 25 '22 10:07 eastriverstudio

Actually another one I forgot to mention above which I'm thinking in my head could also be useful is a layout /other element condition, so if a post has an active layout/element set in Elements we can show some other elements based on that. I see this allowing sort of global template based conditions in situations where having to manually select all posts or pages could be cumbersome between different elements.

Simple example is I have a page hero I want to apply to some pages, but others I want to be created manually in GB. To do this right now it would require me to maually select the pages/post to apply and exclude which is fine but not very future proof to changes. Appreciate I'd still have to set the conditions for the layout element in the first place, but such an option would mean I don't have to manually copy & update conditions between each element for it to work.

I think some folks use taxonomies or front-end filters for this sort of thing right now and that does work, but I guess I'm thinking given how GB is increasing the dynamic features it would be nice to have some more dynamic capabilities within the display conditions of Elements and not have to create additional taxonomies or front-end filters for this.

Would obviously need to think about the praticality of this last one particularly, but I feel something based on element layout or another block element to give us some more template based rules for things such as page hero could be useful.

Thanks

eastriverstudio avatar Jul 25 '22 12:07 eastriverstudio

Hey @eastriverstudio more options are always welcome, and I think most of the ones you are proposing here makes total sense in some use cases.

Currently, we are focusing on GB to enable more features, now we are testing "Related posts" and in the near future we should see some improvements for the meta fields. But after this improvements we will be switching context to GP and GPP Elements cause we have some pretty exciting improvements to be made. And once working in that we are going to keep in mind adding more display rules like the ones you brought here.

Thanks again for the contribution

JeanPaiva avatar Jul 25 '22 14:07 JeanPaiva

I'd like to propose an idea to allow us to create our own custom conditions for the elements?

Just a simple filter that allows us to add a type/location to the $types array in class-conditions.php - get_conditions()

Then allowing us to hook into that condition to write our own logic.

tdrayson avatar Aug 02 '23 09:08 tdrayson

Would love to see an option to specify a parent page and target all child pages with an element. Any plans to add this? @tomusborne

masteradhoc avatar Jul 24 '24 15:07 masteradhoc