You are here: Home Plone Basics Moving a viewlet from a viewlet manager to another one
Search
Advanced Search…
Statistics
Total: 412
Total Pages: 253
Total Folders: 83
Total Files: 14
Total Links: 26
Last modification: 30.08.2010 09:17
 

Moving a viewlet from a viewlet manager to another one

by Wyden Silvan last modified 26.11.2009 12:15

To achieve moving a viewlet from a viewlet manager to another one, we'll have to apply what we already covered in the previous paragraphs:

We have to hide the viewlet from the viewlet manager that we want to take it out from, and register it to the other viewlet manager for the zSubject that corresponds to our theme.

Let's assume that we want to move the portal actions from top to bottom…

in browser/interfaces.py, we need to setup our ZSubject:

from plone.theme.interfaces import IDefaultPloneLayer

class IMyThemeSpecific(IDefaultPloneLayer):
    """Marker interface that defines a ZSubject.
       It will be used for the viewlets that we want to add to the
       "My Theme" skin only.
    """

in browser/configure.zcml:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="mytheme">

    <interface
        interface=".interfaces.IMyThemeSpecific"
        type="zope.publisher.interfaces.browser.IBrowserSkinType"
        name="My Theme"
        />

    <!-- Moved viewlet registration -->
    <browser:viewlet
        name="plone.site_actions"
        manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
        class="plone.app.layout.viewlets.common.SiteActionsViewlet"
        permission="zope2.View"
        layer=".interfaces.IMyThemeSpecific"
        />

</configure>

in profiles/default/viewlets.xml:

<?xml version="1.0"?>
<object>
  <order manager="plone.portalfooter" skinname="My Theme"
         based-on="Plone Default">
    <viewlet name="plone.site_actions" insert-after="*" />
  </order>
  <!-- We hide the one we want to move -->
  <hidden manager="plone.portalheader" skinname="My Theme">
    <viewlet name="plone.site_actions" />
  </hidden>
</object>

Done!

All we did, we did it without touching main_template.pt, isn't it a success?