CHAPTER 5 ADDING AND CUSTOMIZING THEMES 161 (Web site design and hosting)

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 161 The PHP code in template files rarely gets more complicated than this, and most of the time it will suffice if you can recognize which lines and bits belong together, so that you can copy and paste them without introducing errors. Tip To learn more about PHP code, read Beginning PHP5 and MySQL: From Novice to Professional,by W. Jason Gilmore (Apress, 2004). Template Variables Template files are the meeting place of static content (HTML) and dynamic values (variables), as well as minimal logic, similar to the examples shown in the previous section, to account for the numerous variations that are possible in a dynamic site. While there are many approaches and philosophies for templating in general, PHPTemplate has evolved in a way that encourages simple and minimal logic. It uses variables that are pushed into the template from the theme engine. Each template will have a number of variables available to it that are provided by the theme engine. In addition to the variables that are unique to each template, the variables $id and $zebra are always included by PHPTemplate, no matter which template is being called. These variables work as follows: $id: A sequential counter that is incremented every time the template is rendered. In the case of blocks, for example, it allows each block to have a unique ID on the page. $zebra: An alternating counter that has the value oddor even. This is useful for giving table rows alternating colors, for example. Furthermore, the variable $is_front is also available. It is true whenever the front page is being displayed, so you can always write template code like this: — display when on front page – PHPTemplate Template Files Here is an in depth look at the four tpl.php files included with PHPTemplate, as well as the page.tpl.php file that is included with the Bluemarine theme. Block.tpl.php The block.tpl.php file is included with the PHPTemplate engine and is therefore optional within individual themes. It is responsible for calls to theme(’block’) and generates the individual blocks within the various block regions. These are the blocks that you configure from the block administration page (admin/blocks). Table 5-4 lists the variables available in block.tpl.php.
Note: In case you are looking for affordable webhost to host and run your web application check Vision http web server services

Leave a Reply