Can I enable/disable ContentBlocks system-wide, per context, per resource, or based on other factors?
Out of the box, ContentBlocks comes with a few options to decide when it is used and when it isn't. By default, it is enabled for all resources across your MODX site.
To enable or disable ContentBlocks system-wide, go to System (the cog icon in 2.3+) and System Settings. In the first dropdown above the table, choose contentblocks to show all settings that belong to ContentBlocks. Under the Core area, you should see "Disabled" (with key contentblocks.disabled
). Double click its value to edit it. Set to Yes to disable ContentBlocks, and set to No to keep ContentBlocks enabled by default. When set to Yes, so disabled by default, it is possible to selectively enable it on more specific entities, such as contexts.
To enable or disable ContentBlocks in an entire context, create a new context setting for that context by right clicking the context in the tree, choosing Edit Context and clicking the Create New button on the Context Settings tab. Give it a key of contentblocks.disabled, set the Field Type to Yes/No and set a value of 0 (to enable ContentBlocks in that context) or 1 (to disable ContentBlocks in that context).
To enable or disable ContentBlocks on a specific resource, edit that resource and navigate to the Settings tab. Near the bottom of the tab you will notice a Use ContentBlocks? setting. Set it to Yes or No and then save the resource. The page will reload and ContentBlocks is enabled/disabled for that resource.
To enable or disable ContentBlocks based on the template or other factors:
- with ContentBlocks v1.10 and above, you can configure template properties to whitelist or blacklist templates
- with ContentBlocks v1.9 and older, as well as for factors that not currently built-in (e.g. to enable/disable by resource parent), you can use a custom plugin to toggle a resource property. Please see the following examples: enable (whitelist) on specific templates only, or: disable (blacklist) on specific templates.