Skip to content

Commit 8deb818

Browse files
committed
improve viewlet chapter
1 parent a002df8 commit 8deb818

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

docs/classic-ui/viewlets.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,30 @@ You usually map `<viewlet>` to the `browser/configure.zcml` folder.
302302
</configure>
303303
```
304304

305+
#### Overriding a viewlet registration
306+
307+
To change a viewlets manager, we can override the registration in our custom Plone add-on package as follow:
308+
309+
```xml
310+
<!-- move contentleadimage viewlet to different viewletmanager -->
311+
<configure package="plone.app.contenttypes.behaviors">
312+
<browser:viewlet
313+
name="contentleadimage"
314+
for="plone.app.contenttypes.behaviors.leadimage.ILeadImage"
315+
view="plone.app.layout.globals.interfaces.IViewView"
316+
manager="plone.app.layout.viewlets.interfaces.IBelowContentTitle"
317+
class="plone.app.contenttypes.behaviors.viewlets.LeadImageViewlet"
318+
template="leadimage.pt"
319+
permission="zope2.View"
320+
layer="collective.example.interfaces.IExampleLayer"
321+
/>
322+
</configure>
323+
```
324+
325+
the override is done here, with the help of a browser layer.
326+
An alternative way would be to put the registration without a browser layer into a overrides.zcml in the package root of your add-on.
327+
328+
305329

306330
### Conditionally rendering viewlets
307331

@@ -786,7 +810,7 @@ These settings are stored in the site database.
786810
A good practice is to export {file}`viewlets.xml` using `portal_setup`, and then include the necessary bits of this {file}`viewlets.xml` with your add-on installer, so that when your add-on is installed, the viewlet configuration is changed accordingly.
787811
788812
```{note}
789-
You cannot move viewlets between viewlet managers.
813+
You cannot move viewlets between viewlet managers TTW.
790814
Hide the concerning viewlets in one manager using `/@@manage-viewlets` and {file}`viewlets.xml` export, then re-register the same viewlet to a new manager.
791815
```
792816

0 commit comments

Comments
 (0)