-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Site Editing: Plugin conditional templates #29076
Comments
@Sandstromer What happens right now? Do the blocks show as missing? |
It very much depends on the block. For example, some blocks will display - on the frontend - the html parts of the block but not the dynamic content. With block patterns we can conditionally make them available because we use php. I'm not sure whether we need conditional templates, or whether we can make do with block patterns? Would love to hear some more thoughts on this. |
Is this the correct ticket in which to mention conditional block display? For example, I need to be able to switch between a query loop and a "no posts found" message in e.g. block-templates/index.html. Is this not possible, or have I just not found the documentation yet? Without this, we're blocked from using the FSE features for all of our sites. |
I'd like to point out that this should be applicable not only for templates but also template parts. (As described in #51987) In my opinion, the most flexible solution would be to provide a "templateParts": [
{
"title": "Product archive content",
"name": "woocommerce-archive-product",
"conditionCallback": "is_woocommerce_active"
}
],
"templates": [
{
"title": "Product archive",
"name": "archive-product",
"conditionCallback": "is_woocommerce_active"
}
] The I'm aware there is no |
What problem does this address?
Should a theme author wish to include a template that includes blocks(s) from another plugin, the template is available to edit/use without the dependent plugin being active.
Examples could be a product template designed to work with WooCommerce blocks, or a header template containing the WC product search.
There could be confusion should a user select the header template for use on a site where WooCommerce is not in use.
What is your proposed solution?
Have some way of a theme defining when a particular template/template part is available for use in the editor.
Could this be included in theme.json?
e.g.
Run a check to see if the plugin in the
woocommerce
directory is active. If so, make theshop-header
template available in the editor.The text was updated successfully, but these errors were encountered: