Reordering and Hiding viewlets
We saw in the previous paragraph that viewlets ordering is stored in a utility. That utility is set up from the viewlets.xml file of a Generic Setup profile.
Ordering
If all you need is to reorder the viewlets in the Plone Default skin, you can simply copy the original viewlets.xml from CMFPlone/profiles/default/ into MyTheme/profiles/default/, and edit the copied file to make it reflect your needs.
But you may want to order viewlets with more flexibility. Be happy: there are handy parameters for each node in viewlets.xml.
Let's see how would look a viewlets.xml file for a 3rd party theme product:
<?xml version="1.0"?>
<object>
<order manager="plone.portalheader" skinname="My Theme"
based-on="Plone Default">
<viewlet name="plone.logo" insert-before="*"/>
</order>
<order manager="plone.portaltop" skinname="*">
<viewlet name="plone.app.i18n.locales.languageselector"
insert-after="plone.path_bar"/>
</order>
</object>
The above code contains two <order /> declarations: The first one creates a new skin named My Theme which is based on the Plone Default one. This means that the new skin inherits from the viewlets ordering of the skin it is based on. In our example, the plone.logo is moved at the first position in the plone.portalheader viewlet manager. The second declaration moves plone.app.i18n.locales.languageselector right after plone.path_bar in the plone.portaltop viewlet manager for all skins (notice the skinname="*" statement).
- Note
Both DIYPloneStyle and ZopeSkel add a viewlets.xml file when generating a blank theme product (use --add-viewlet-example with the DIYPloneStyle generator script).
For your convenience, you can find inline documentation about the parameters that can be used in the generated file (It is an option with ZopeSkel, answer 'True' when it asks for it).
Hiding
Hiding a viewlet is also done from the viewlets.xml with the <hidden /> node which is at same level as <order />, and is done per skin selection.
For instance, if you need to remove the global sections for your skin, you'd have to add some declaration like the following one to viewlets.xml:
<hidden manager="plone.portalheader" skinname="My Theme"> <viewlet name="plone.global_sections" /> </hidden>
Unhiding
If, for any reason, you need to unhide one or more viewlets for a given viewlet manager, you can make use of the purge and remove node parameters in your <hidden /> declaration in viewlets.xml.
To unhide all hidden viewlets for a given viewlet manager:
<?xml version="1.0"?>
<object>
<hidden manager="plone.portalheader" skinname="Plone Default"
purge="True" />
</object>
To unhide specific viewlet(s):
<?xml version="1.0"?>
<object>
<hidden manager="plone.portalheader" skinname="Plone Default">
<viewlet name="plone.global_sections" remove="True" />
</hidden>
</object>
- Note
- The purge and remove node parameters are also supported inside the <order /> declaration.
Nothing that difficult here ;-)
changes to take effect ?
yes, can you propose a procedure for changes to be correctly updated ?
do we need only to uninstall/reinstall product ? restart plone ?
Thanks
Emmanuel
Help !!!
only uninstalling/reinstalling product ?
i try many things (install/restart/uninstall etc ..) but order still the same, my change are not take into account ...
thanks for help
changes
you need to follow this path in order to get changes applied:
- Restart the Zope server
- Go to Site Setup > Addon products > uninstall/reinstall your theme
Problems with changes not taken in account were experienced with Plone 3.0.1, but I could not reproduce anymore on Plone 3.0.2.
Make sure you have latest Plone stable release.
still issue in 3.0.2
i installed a fresh Plone 3.0.2 on my ubuntu box.
Plone 3.0.2
CMF-2.1.0
Zope (Zope 2.10.4-final, python 2.4.4, linux2)
Python 2.4.4 (#1, Oct 27 2007, 16:43:26) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)]
PIL 1.1.6
i add product DotNetTheme, apply theme ... all is working perfect
BUT
i change the viewlets.xml to
<?xml version="1.0"?>
<object>
<order manager="plone.portalheader" skinname="DotNet Example"
based-on="Plone Default">
<viewlet name="dotnet.logo" insert-before="plone.searchbox" />
</order>
<order manager="plone.portaltop" skinname="DotNet Example"
based-on="Plone Default">
<viewlet name="plone.personal_bar" insert-before="*" />
</order>
<hidden manager="plone.portalheader" skinname="DotNet Example">
<viewlet name="plone.logo" />
<viewlet name="plone.global_sections" />
</hidden>
</object>
after restarting Zope/uninstall/reinstall product the logo do not change order according last viewlets.xml changed.
feel to contact me for more detail ...
refresh
version.txt still no refresh
<order manager="plone.portalheader" skinname="DotNet Example"
based-on="Plone Default">
<viewlet name="dotnet.logo" insert-before="plone.searchbox" />
</order>
The dotnet.logo still before plone.site_actions.
(i'm going to be crazy ....)
thanks for help
reordering
i'll investigate on it
thanks
Re: A note on uninstaling/installing the product for changes to take effect
You first of all need to change version.txt. After this, go to the Products control panel. It should detect that the version of your product has changed and ask you if you want to re-install it. Click on the re-install button and your viewlets.xml changes will be reflected.
In my view, this is a diasterous way to manage the process of developing a theme. I can only speak for myself, but pretty much the first thing that I want to do with a Plone installation for a client is to implement their theme. It is a really slow process when you have to keep repeating the process above to see changes. I would prefer to see some kind of debug mode for products that avoided this process.
viewlet problems with plone 3.02
I've been changing the verson number like someone here suggested, and that works ok for reinstalling the product. I've also done it with restarting Zope, and uninstalling and reinstalling the product. Thanks for any ideas or fixes!
Hiding vs removing
Won't work
By default in Zope 3, all viewlets are rendered, but no order is applied.
The Plone 3 layer added to Zope viewlets make them appear that way: Plone first renders ordered viewlets in the right order, then remaining registered ones which order is not defined in the tool.
The only way to remove a viewlet from its viewlet manager is to declare it in the hidden node of viewlets.xml.
A note on uninstaling/installing the product for changes to take effect
Just to suggest adding a note about uninstalling/reinstalling the product containing your changes in the site setup page. I couldn't make my changes to viewlets.xml take effect until I did this.