QTT: Custom Templates in Kaizen CMS
First a brief intro into Kaizen. Kaizen CMS is still a relatively new (or at least new to the public) content management system that was started by John Hoover back in 2007. The cms that exists today is far from the initial and started to take shape in August of ’09 and released as open source to the public in January 2010. I’ve worked with John for over a year now (at DigiMedia and now at Crane|West) and joined him in development of this project in October ’09. It still has areas we are improving on but is the basis we start all of our sites with. The source is hosted on Github and the project is opensource so feel free to fork and explore the code. The project is in active development with lots of improvements in the works.
Now onto the quick tip for today. I’m going to show you how easy it is to create a custom template in Kaizen CMS. Its honestly as easy as one line of code and the cms already has an example of this in ./views/content/contact.tpl file. A custom template is a great way to provide a different look to different pages without affecting the overall site appearance. You might have a page that you don’t want the sidebar to show up on or a page with a completely different header and footer. Kaizen allows you to do this easily without almost no effort on your part. We use smarty for the templates as well. Lets look at the code for the main content template (./views/content.tpl).
1 2 3 4 5 6 7 8 9 10 | {include file="inc_header.tpl" page_title=$aContent.name|clean_html menu=$aContent.tag} <section id="content" class="content"> <h2>{$aContent.title|clean_html}</h2> {$aContent.content|stripslashes} </section> {include file="inc_sidebar.tpl"} {include file="inc_footer.tpl"} |
Line 1 does three things. First it includes your header file, in this case it’s inc_header.tpl, then it sets the page title using the content name (page title set in the admin) and last it sets the menu tag (this lets you tell what page your on and can then set a class on your menu to show that. Line 4-5 is displaying the content for the page, so nothing special. Line 8 & 10 are just including the sidebar and footer.
(more…)
