-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional Blocks? #6866
Comments
Can you share more details about your idea? How do you see it working exactly? Is there any particular use case you have that it would solve? |
Hi Greg, Say you have a Landing Page, and you have a variety of blocks dealing with your business. In a list maybe they're like:
But, you want to only show 1 and 4 if the business is a brick and mortar. That would be an example of a conditional. |
Related: There is already a plugin called |
@Soean Eh... Doesn't look like all that much really. I appreciate you suggesting something, but this doesn't really come close to a solution for what I'm proposing/asking about. |
@bahia0019 I know its not a perfect solution, I just wanted to post it as an example https://block-options.com/features/. So you should see it more as an Inspiration. I like to see this kind of feature in core. |
@Soean Thank you very much for suggesting Block Options! @bahia0019 you can use the Display Logic option to add conditional statement. I do have more features that will be very helpful for what you are looking for. Will keep you posted once those features are available. Cheers! |
Closing, as it seems like this can be addressed with a plugin for the time being. |
@bahia0019 I've decided to add ACF support already to Block Options plugin :) I haven't uploaded this feature yet but here's the preview. Let me know if you're up for testing. Thank you very much! |
@phpbits I don't understand what that is supposed to do. |
@bahia0019 sorry, I misunderstood! I thought you are looking for a way to make the block visibility dependent on ACF. |
I do believe a conditional block would be great to have for various elements of a page that we would like to define where these are to be seen. Inside a conditional block one could add a sidebar/footer/menu/header or any other block. Btw Perhaps even add conditional logic to the container block. (I am not able to find the issue for the container block right now.) The container block is meant to have child blocks inside of it. It would be great to add a phase two label to this issue @danielbachhuber @melchoyce |
@paaljoachim this is intriguing! How exactly would the conditional logic work in this case? My concern is that the steps shown above might be a bit much for the use case we've been discussing on the Make blog. If I'm going to add a conditional block, I more care about just saying "this goes across the entire site". I welcome thoughts on this! At the moment it feels like the use case for conditionals might need some tweaking to fit for something such as the nav block. Thanks! |
Hey @jwold Most blocks have an advanced area in the sidebar settings. I would suggest that we actually use it. (Today it seems to mainly be used to create another CSS class.) How to easily setup conditionals is something we will need to look closer at. By using the Advanced section. This is what it could look like when open. Clicking the Pages accordion then shows all the pages. User clicks the pages and they get listed next to the Pages title showing which pages the container will be seen in. Similar to when selecting a color one sees the color preview tiny box next to the color background title. As it gives an overview of what has been selected. Of course I am probably missing conditionals that should be added, but it gives a nice overview of how I see it can be done. |
Ok, this is becoming clearer to me. Thanks for clarifying!
|
For a use case, I just wanted to add a couple of thoughts based I'm something I'm looking at doing:
If a conditional engine is built, with maybe a few conditions to start, others may create add-on conditions just as others are now coming up with add-on blocks. In fact, some creating specific blocks, such as a weather type block above, might come up with their own conditions specific to the block they designed. Just adding more thoughts. Thanks! |
Wicked Block Conditions can be used to show or hide blocks based on conditions like user login status and role. |
More plugins are popping up |
Wrote another plugin today. maybe helpful for someone. Very early development. Not production ready. No docs yet.
|
I wrote a plugin to show/hide Gutenberg Blocks called "Block Logic". It is very flexible and supports hiding/showing of blocks based on all sorts of conditions or functions, even your own function, should you want to write one. Would be happy if anyone finds it useful! |
It is awesome that people post their Conditional plugins here! Here is one more Conditional plugin. This one focused on a show and hide feature. |
Thanks for the comment @paaljoachim! Lots of new functionality coming to Block Visibility. If anyone has a feature request, let me know! |
Is there a plan for a conditional block?
The text was updated successfully, but these errors were encountered: