For a customer I needed to have an old school custom Plone template not to be cashed. The site was put behind varnish and just adding “no-cache” headers did not work.
The solution was creating an extra rule in the “Cache Configuration Tool” (http://yourplonecms.com/portal_cache_settings/with-caching-proxy/rules), which allows for quite a lot of customization.
To the top of the existing rule set, add a copy of the plone-templates. In the rule under “Templates” add your template id and for the “Header Set for …” set both dropdowns to “Do not cache”. This should do the trick, at least it did for me.
On http://transcyberia.info/archives/39-customizing-navigation-in-Plone3.html I found a great article on how to subclass the navigation portlet. Explanations and all. This entry is based on that article but doesn’t have all the nice explanations.
For a generic plone 3 portlet with a template portlet.pt and a module named portlet.py, this is what you need to do to subclass it. I tend to create a portlets folder in my porducts, which you have to register in the same way as the browser folder from your theme is registered. Don’t forget the __init__.py and a configure.zcml!
Copy portlet.pt template from the source egg into your theme’s portlets/ directory. Don’t copy portlet.py, but instead create your own portlet.py. It needs only the following measly five lines of code:
from source.egg.portlet import Renderer
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class MyPortletRenderer(Renderer):
render = ViewPageTemplateFile('portlet.pt')
In portlets/configure.zcml put the following lines:
<plone:portletRenderer
portlet="source.egg.portlet.IPortletInterface"
layer=".interfaces.IThemeSpecific"
/>
If, like in this example, the template in the renderer is called render (so render = ViewPageTemplateFile(‘portlet.pt’)) and not index or _template or something the like, you just use the template instead of creating a class for it in a special portlet.py. The subclassing also works with multiple templates or differently named ones.
<plone:portletRenderer
portlet="source.egg.portlet.IPortletInterface"
template="portlet.pt"
layer=".interfaces.IThemeSpecific"
/>
Recent Comments