Skip to content

Commit 75ce86e

Browse files
committed
Disabling Diazo: Document how to disable diazo for AJAX requests and completly.
1 parent 9be64d8 commit 75ce86e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/classic-ui/theming/diazo.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,52 @@ For instance, you may need to put together the main menu, the language change, a
176176
Sometimes it is easier to override the corresponding template in Plone, build the new HTML structure there, and replace one thing in the {file}`rules.xml` file than trying to write complex Diazo rules or writing XSLT.
177177

178178
The size of the {file}`rules.xml` file and the number of rules it contains can negatively impact the performance of your site.
179+
180+
181+
### Disabling Diazo for AJAX requests
182+
183+
You can disable AJAX requests for Diazo themes with the help of the `ajax_load` parameter.
184+
This parameter is used in some places throughout Plone to indicate AJAX requests, which normally should not be transformced by Diazo.
185+
Also, in Plone 6.2 the `ajax_load` parameter will [automatically be added to the request](https://github.com/plone/Products.CMFPlone/pull/4169) for all AJAX requests.
186+
187+
Firs you need a theme-parameter in your {file}`manifest.cfg` file.
188+
189+
```cfg
190+
[theme:parameters]
191+
ajax_load = python:request.get('ajax_load')
192+
```
193+
194+
Then you can disable Diazo for AJAX requests in your {file}`rules.xml` file:
195+
196+
```xml
197+
<notheme if="$ajax_load" /><!-- don't theme ajax requests -->
198+
```
199+
200+
After that you would need to restart you instance and reload your theme.
201+
One way is to select another theme and then switch back to your own theme in the theming control panel.
202+
For a programmatical way, check [this pull request in plonetheme.barceloneta](https://github.com/plone/plonetheme.barceloneta/pull/404).
203+
204+
205+
### Completly disable Diazo
206+
207+
You might want to not use Diazo for your theme and fully disable it.
208+
This can be done by setting the `X-Theme-Disabled` http header before Diazo gets active, e.g. in a `IBeforeTraverseEvent` event subscriber.
209+
210+
In this example we add an event subscriber in e.g. a {file}`subscribers.py` file in a add-on package:
211+
212+
```python
213+
def disable_diazo(obj, event):
214+
event.request.response.setHeader("X-Theme-Disabled", True)
215+
```
216+
217+
And then it needs to be registered in a {file}`configure.zcml` file:
218+
219+
```xml
220+
<subscriber
221+
for="*
222+
zope.traversing.interfaces.IBeforeTraverseEvent"
223+
handler=".subscribers.disable_diazo"
224+
/>
225+
```
226+
227+
Now Diazo should be disabled for all requests.

0 commit comments

Comments
 (0)