registering a viewlet for multiple interfaces

classic Classic list List threaded Threaded
5 messages Options
Kees Hink Kees Hink
Reply | Threaded
Open this post in threaded view
|

registering a viewlet for multiple interfaces

Can i register a viewlet for more than one interface in a DRY way? Currently,
I'm just replicating the browser:viewlet section, changing only the interface,
like so:

  <!-- Show doormat on Homepages -->
  <browser:viewlet
      name="groningerforum.doormatcontainer"
      for="Products.CMFCore.interfaces.ISiteRoot"
      manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
      template="templates/doormat_container.pt"
      layer=".interfaces.IForumBaseTheme"
      permission="zope2.View"
      />
  <!-- Show doormat on ForumEvents -->
  <browser:viewlet
      name="groningerforum.doormatcontainer"
      for="Products.GroningerForum.content.interfaces.IForumEvent"
      manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
      template="templates/doormat_container.pt"
      layer=".interfaces.IForumBaseTheme"
      permission="zope2.View"
      />

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Vitaliy Podoba-2 Vitaliy Podoba-2
Reply | Threaded
Open this post in threaded view
|

Re: registering a viewlet for multiple interfaces

Kees Hink wrote:

> Can i register a viewlet for more than one interface in a DRY way?
> Currently, I'm just replicating the browser:viewlet section, changing only
> the interface, like so:
>
>   <!-- Show doormat on Homepages -->
>   <browser:viewlet
>       name="groningerforum.doormatcontainer"
>       for="Products.CMFCore.interfaces.ISiteRoot"
>       manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
>       template="templates/doormat_container.pt"
>       layer=".interfaces.IForumBaseTheme"
>       permission="zope2.View"
>       />
>   <!-- Show doormat on ForumEvents -->
>   <browser:viewlet
>       name="groningerforum.doormatcontainer"
>       for="Products.GroningerForum.content.interfaces.IForumEvent"
>       manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
>       template="templates/doormat_container.pt"
>       layer=".interfaces.IForumBaseTheme"
>       permission="zope2.View"
>       />

AFAIK this is the only way to register viewlet for different interfaces.
Otherwise, from python code.

/Vitaliy Podoba

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Hedley Roos-2 Hedley Roos-2
Reply | Threaded
Open this post in threaded view
|

Re: registering a viewlet for multiple interfaces

You need to add a marker interface to both SiteRoot and ForumEvent, eg.

<class class="Class.Path.To.SiteRoot">
       <implements interface=".interfaces.IMyMarkerInterface" />
</class>

<class class="Products.GroningerForum.content.ForumEvent">
       <implements interface=".interfaces.IMyMarkerInterface" />
</class>

and then register the viewlet with for=".interfaces.IMyMarkerInterface".

I haven't done this but it should work.

Hedley Roos
_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Kees Hink Kees Hink
Reply | Threaded
Open this post in threaded view
|

Re: registering a viewlet for multiple interfaces

That _would_ be an improvement. Thanks!

On 06/03/2010 10:25 AM, Hedley Roos wrote:

> You need to add a marker interface to both SiteRoot and ForumEvent, eg.
>
> <class class="Class.Path.To.SiteRoot">
>        <implements interface=".interfaces.IMyMarkerInterface" />
> </class>
>
> <class class="Products.GroningerForum.content.ForumEvent">
>        <implements interface=".interfaces.IMyMarkerInterface" />
> </class>
>
> and then register the viewlet with for=".interfaces.IMyMarkerInterface".
>
> I haven't done this but it should work.
>
> Hedley Roos
_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Kees Hink Kees Hink
Reply | Threaded
Open this post in threaded view
|

Re: registering a viewlet for multiple interfaces

In reply to this post by Hedley Roos-2
Tried it, and it works. Thanks!

On 06/03/2010 10:25 AM, Hedley Roos wrote:

> You need to add a marker interface to both SiteRoot and ForumEvent, eg.
>
> <class class="Class.Path.To.SiteRoot">
>        <implements interface=".interfaces.IMyMarkerInterface" />
> </class>
>
> <class class="Products.GroningerForum.content.ForumEvent">
>        <implements interface=".interfaces.IMyMarkerInterface" />
> </class>
>
> and then register the viewlet with for=".interfaces.IMyMarkerInterface".
>
> I haven't done this but it should work.
>
> Hedley Roos
_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers