[Framework-Team] plone.theme - one more package for Plone 3?
whit
d.w.morriss at gmail.com
Mon May 21 21:51:56 UTC 2007
Martin Aspeli wrote:
> Hi guys,
>
> David, Florian and I were discussing the skinning story in Plone 3.
> David was a bit frustrated trying to customize things like the portal
> logo in a clean way. We made some headway, but discovered that it
> wasn't very easy to make use of Zope 3 browser layers in Plone.
>
> For those not familiar with them, browser layers are markers which are
> applied to the request during traversal. You can register views,
> viewlets etc for a particular layer marker, either to override a view
> for a particular skin/theme, or to make sure a particular viewlet is
> only shown in a particular skin/theme.
>
> For example:
>
> <browser:viewlet
> name="my.viewlet"
> for="*"
> layer=".interfaces.IMyTheme"
> manager="plone.app.layout.viewlets.interfaces.IAboveContent"
> template="myviewlet.pt"
> permission="zope2.View"
> />
>
> This will only show up if the IMyTheme skin/browser layer is applied.
>
> The most obvious way for this to would be for IMyTheme to correspond
> to a particular theme/skin as selected in portal_skins.
>
> That's where plone.theme comes in. It provides an event handler
> listening to IBeforeTraverseEvent, and will attempt to match a browser
> layer marker to the current skin selection.
>
> To use it, let's say you have "My Theme" in portal_skins. You could
> then have a marker interface like:
>
> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>
> class IMyTheme(IDefaultBrowserLayer):
> """Marker interface used in the tests
> """
>
> and in configure.zcml:
>
> <interface
> interface=".interfaces.IMyTheme"
> type="zope.publisher.interfaces.browser.IBrowserSkinType"
> name="My Theme"
> />
>
> The trick here is that the name of the IBrowserSkinType utility
> matches the name of the skin selection/theme in portal_skins.
>
> The code is here:
>
> http://dev.plone.org/plone/browser/plone.theme/trunk/plone/theme
>
> It's pretty simple, and there are (doc)tests. It should be pretty low
> risk.
>
> Now, nothing in Plone core uses this (though NuPlone could use it,
> perhaps). I can release this to the Cheese Shop and things like
> DIYPloneStyle can depend on it. However, it may be useful to
> integrators and customisers if this is part of the Plone 3
> distribution, and its ZCML was loaded from Products/CMFPlone to avoid
> slugs or needing to include it explicitly.
>
> I can manage the release and add it to the lib bundle and ploneout, if
> no-one objects to it going in at this (admittedly late) stage.
>
> Martin
>
I would say this point you are at wiggy's mercy.
-w
--
------ d. whit morriss ------
- senior engineer, opencore -
- http://www.openplans.org -
- m: 415-710-8975 -
"If you don't know where you are,
you don't know anything at all"
Dr. Edgar Spencer, Ph.D., 1995
-------------- next part --------------
A non-text attachment was scrubbed...
Name: whit.vcf
Type: text/x-vcard
Size: 291 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-framework-team/attachments/20070521/72d55efb/attachment.vcf>
More information about the Framework-Team
mailing list