Drupal theme engine - What is PHPTemplate?

          

Working with Theme Engines


What is PHPTemplate?

PHPTemplate is one of a family of applications known as templating engines (referred to frequently in Drupal—and in this text—as "theme engines"). These applications serve a middleware function and determine the coding syntax, which will be used to create the theme. As the name implies, PHPTemplate supports the popular PHP programming language for theme creation.

PHPTemplate was built by developer Adrian Rossouw, and was created specifi cally for use with Drupal. PHPTemplate is the most widely supported theme engine for Drupal and is compatible with Drupal 4.6 and up. PHPTemplate is included in the default distro of the Drupal 5 series.


 By Ric Shreves 


This excerpt from Chapter No. 3 "Working with Theme Engines" of Drupal 5 Themes  by Ric Shreves, is printed with permission from Packt Publishing, Copyright 2007. 

Your default PHPTemplate engine fi les are located on your server in the directory themes/engines/phptemplate; additional theme fi les will appear in the theme directory of each individual PHPTemplate-enabled theme. 

How does it Work?

PHPTemplate is a tool that helps separate the tasks of the programmer from the tasks of the designer. As a tool, PHPTemplate makes it possible for web programmers to work on the business logic of an installation without having to worry too much about the presentation of the content. In contrast, web designers can focus entirely on the styling of discreet blocks of content and items, comprising the layout and the interface. Developers and designers can divide their tasks and optimize their work.  

 
Building themes with a theme engine represents a more manageable way of handling dynamic web applications. Every PHPTemplate theme fi le contains an HTML skeleton with some simple PHP statements for the dynamic data. The theme fi les are linked together with the CSS fi les, allowing the dynamic data to be styled and formatted with ease. In other words, PHPTemplate takes one big step towards the oft-heard holy grail of separating the presentation from the content.

The logic included in a PHPTemplate fi le is generally rather basic, relying primarily on the use of if statements and includes. Much of the code you will see is even more basic and relates purely to the formatting—CSS styling and basic HTML.

The fi les contained in the PHPTemplate directory on the server (themes/engines/ phptemplate) work in conjunction with the fi les located in the active theme's directory (principally the page.tpl.php file) to produce the resulting output. The page.tpl.php fi le is the only PHPTemplate fi le required to enable a theme to employ the theming engine; likewise, all PHPTemplate themes will have this fi le inside the theme's directory.

Template files are written in PHP and contain a series of includes and conditional statements designed to detect the presence of elements that must be added into the fi nal output. The includes and conditional statements relate to things like the content of the site title, the presence and location of a logo fi le, the number of active regions, boxes, etc. Whether a statement is satisfi ed, and the content displayed, is often the product of decisions made by the site administrator in the process of confi guring the site as well as decisions made during the creation of content and functionality.

Click here to read full Chapter No. 3 "Working with Theme Engines" of "Drupal 5 Themes"   



Write your comment - Share Knowledge and Experience


 

Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring