[Zope3-Users] Seeking a ZCML Example for a CSSViewlet

Darryl Cousins darryl at darrylcousins.net.nz
Sat Oct 7 00:00:11 EDT 2006


On Fri, 2006-10-06 at 20:29 -0500, Jeff Rush wrote:
> I've got viewlets working fine (really cool too!) but I'm stumped on getting a
> CSSViewlet declared.  Googling doesn't show anyone using CSSViewlets but
> hopefully someone who implemented it might clarify.

> Help please?
> 
> -Jeff

Hi Jeff,

I do it like this (forgetting where the boilerplate came from - thanks
to someone).:

python code::

BRSPublicLayerLayoutCSSViewlet = zope.viewlet.viewlet.CSSViewlet('style/layout.css', 'all')

configure zcml::

  <browser:viewlet
      name="layout.css"
      for="*"
      manager="barrysmithgallery.layer.public.ICSS"
      permission="zope.Public"
      class="..BRSPublicLayerLayoutCSSViewlet"
      layer="barrysmithgallery.layer.public.IBRSPublicBrowserLayer"
      weight="2"
      />

And the manager:

python code::


class ICSS(zope.viewlet.interfaces.IViewletManager):

configure zcml::

  <browser:viewletManager
      name="barrysmithgallery.layer.public.ICSS"
      provides="barrysmithgallery.layer.public.ICSS"
      layer="barrysmithgallery.layer.public.IBRSPublicBrowserLayer"
      permission="zope.Public"
      />

And it gets into main template::

 <tal:block replace="structure provider:barrysmithgallery.layer.public.ICSS" />

Hope this helps.

Best regards,
Darryl



More information about the Zope3-users mailing list