Inspired by Torvald de Boskat, the testing underground is proud to present z3c.jbot (just a bunch of templates).
Here's how it works. First you need to register a template overrides directory.
<include package="z3c.jbot" file="meta.zcml" />
<browser:templateOverrides
directory="templates" />
Say you want to provide a different template for /plone/app/layout/viewlets/logo.pt.
Simply put a file called plone.app.layout.viewlets.logo.pt in your template overrides directory, restart, and you're done.
16 comments:
That's really cool. Our template developer is going to pee himself!
This. Does. Not. Suck. At all.
PLIP it for 3.1?
Nice. It really will make life of integrators slightly easier. Though I wonder how does it behave with viewlets, defined with the class. I think it's impossible to override templates for those viewlets (portal_siteactions for example) without overriding their class. If yes, then this way just adds complexity in my opinion, since people will need to know 2 approaches for viewlets' overriding instead of one. Can you tell how this way behaves with class-based viewlets?
Ah, logo viewlet *is* class-based. So, seems like this technique is really cool then. I should definitely try this.
Ooooh, I like this. :-)
@Jon - inclusion in plone core may be a good idea, but note that it's absolutely not a pre-requisite. Unless I'm missing something, this is a standalone package. Put "install_requires='z3c.jbot'" in your setup.py and you can just start using it. Today.
It may be better of this approach matures outside the Plone core for a bit, not at least to encourage alternatives to be explored. Still, it sounds like a solid convention-over-configuration type pattern, so I would welcome a PLIP too.
Thanks for the feedback everyone. Just a note that I've fixed the package so it works in production mode as well.
claytron is right. I just peed myself. This is really cool!
oooohhhh Heading home to change my pants
when can we look forward to using this? :)
I'm using it. Just easy_install z3c.jbot or add it to your buildout. There's further instructions in the README.txt.
dear all, i'm zope/plone newbie and this post makes my task to create a custom skin for a plone instance much easier; however, one problem: installed the egg and followed instructions from readme (put the respective package include into meta.zcml in my skin-product) and get a ZopeSAXParseException "unbound prefix" - probably a beginners error, any hints for me? thanks a lot
You need to add a declaration for the browser namespace; see any browser/configure.zcml in the plone packages.
thanks, works perfectly!
It doesn't seem possible to use a 'layer' with the templateOverrides directive, e.g. layer=".interfaces.IThemeSpecific". This would be nice so that you aren't overriding the templates for all Plone sites in the instance. Any thoughts on that?
Certainly with the current approach, this is possible but would probably hurt performance a lot.
There's only one instance of the PageTemplate object and it would have to compile the template each time we change the source (discriminated on the layer).
To support layers like this we'd need to spawn new PageTemplate object instances for each different file source and then choose the right instance on the render method.
This approach needs some considering I think, but I can certainly see that it's useful to support layers.
Post a Comment