Skip to content

Commit 0ad96b4

Browse files
committed
add overrides examples to layers.md
1 parent 13d5766 commit 0ad96b4

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

docs/classic-ui/layers.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,54 @@ Then views and viewlets from your product can be enabled on the site instance us
5858
### Unconditional overrides
5959

6060
If you want to override a view or a viewlet unconditionally for all sites without the add-on product installer support, you need to use `overrides.zcml`.
61+
You can override classes and templates in this file.
6162

62-
```{todo}
63-
Explain how to use an `overrides.zcml`.
63+
Overide a class:
6464

65-
See https://github.com/plone/documentation/issues/1426
65+
```xml
66+
<browser:viewlet
67+
name="plone.site_actions"
68+
manager="plone.app.layout.viewlets.interfaces.IPortalHeader"
69+
class=".yourViewlet.YourClassViewlet"
70+
permission="zope2.View"
71+
layer="your.app.interfaces.IYourAppLayer"
72+
/>
73+
```
74+
75+
Overide a template:
76+
77+
```xml
78+
<browser:viewlet
79+
name="plone.logo"
80+
for="*"
81+
template="your-logo.pt"
82+
permission="zope2.View"
83+
layer="your.app.interfaces.IYourAppLayer"
84+
/>
85+
```
86+
You can combine both as well. For example, you can override a class and use a different template for it:
87+
88+
```xml
89+
<browser:viewlet
90+
name="plone.site_actions"
91+
manager="plone.app.layout.viewlets.interfaces.IPortalHeader"
92+
class=".yourViewlet.YourClassViewlet"
93+
template="your-logo.pt"
94+
permission="zope2.View"
95+
layer="your.app.interfaces.IYourAppLayer"
96+
/>
6697
```
6798

99+
If you want to override a viewlet or view of a specific add-on product, you need to use enheritance the Layer interface of the add-on product into your own Layer interface.
100+
For example, if you want to override the `sidebar` viewlet of the `collective.sidebar` add-on product, you need to create a new Layer interface and inherit from the `collective.sidebar` Layer interface.
101+
102+
```python
103+
from collective.sidebar.interfaces import ICollectiveSidebarLayer
104+
105+
class IYourAppLayer(ICollectiveSidebarLayer):
106+
"""Marker interface that defines a browser layer."""
107+
108+
```
68109

69110
(classic-ui-creating-a-layer-label)=
70111

0 commit comments

Comments
 (0)