I’m doing a Plone site at work for a client. It’s great because the client will be able to manage their site once it’s up, with a WYSIWYG editor. One of the things I ran into was that the client needed to have 3 different page templates for documents. Two of the templates, child pages and landing pages, are the same except for one <div> and then the third, popup pages, is completely unique.
The way I set this up first going into portal_metadata and adding “Child Page”, “Landing Page” and “Popup Page” to the Document CMF type’s Subjects. Then, I went in to my main_template and added

<div tal:define="global isPopUp python:test('Popup Page' in contentSubjects, 1, None);
global isLandingPage python:test('Landing Page' in contentSubjects, 1, None);
global displayContact python:test('Contact Form' in contentSubjects, 1, None)">

Screengrab of the edit screenThis checks to see if the the the page type is selected and then I use tal:condition= to test whether to display <div>s. The benefit of doing it this way is that the client can change the template type at will, by going into the document properties and selecting the page type in the subject box. The downside is that the main_template has become somewhat unwieldy, but I’ll probably break it up into multiple templates. I suspect that would be even easier if I learned METAL


Leave a Reply