EZPT: Templating Best Practices
After a week of intense work on EZP templates, it quickly becomes apparent where you have made mistakes with the designing of your templates. Most of this stuff is just common sense, if anyone has any other pointers please comment, or post URLs for where this has been discussed.
CSS Rocks
EZP works best with CSS based templates. You’ll notice this most when you need to create a template for a container which will contain a list of various other items. When using CSS, you can use generic code (such as <li> for the list items) and then apply specific classes to the container to modify the look in that page. Since I was delivered a table based html layout for this project, I learned this the hard way.
Override, override, override
The power of EZP comes into play when it comes to overriding the default templates. The power is there to override anything from default datatypes (I had to change the textarea datatype to have fewer than the default 70 rows) to individual objects, classes or sections. There are a couple pitfalls you’ll have to watch for:
- Use Sections: When you want to change the look of a section of your site (ie: I want all the articles in my knowledgebase to have a blue headline) create a section for knowledgebase and then create an override for the class within the section.
- Create a strategy for your override precedence: I had some trouble with overrides taking precedence over other overrides until I came with a basic strategy. Node overrides take precedence (places 1-10), Class overrides come next (11-20, then Section overrides (places 20+), and finally any global overrides. You may not have this many overrides, my main issue was with the “node/view/full.tpl” template.
- Create a strategy for your override naming: If you have a lot of templates you’re managing and if you, like me, prefer to edit your templates outside EZP, you’re going to want to have a naming strategy for your templates. I’m using (type_of_override)_(class)_(section)_(node).tpl. So an override for articles in knowlegdebase would be full_article_knowledgebase.tpl. If I am doing a node override it would be full_42.tpl.
- Create generic templates. I started out creating some very specific templates, before I realized that generic templates which span over a wider range of nodes/classes will be easier to manage. If you need more specific templates after that you can always override your overrides
- Don’t re-invent the wheel: I found myself creating templates which were just containers for other list items. Don’t re-invent the wheel, use (or override) the container template and then modify the list templates for the sub items.
And finally CTCS
This is one that I learned in IRC as well as from a couple of head banging sessions which turned out were caused by me not clearing the cache. Clear the Cache Stupid, ask questions later.



