Web hosting bandwidth - CHAPTER 5 ADDING AND CUSTOMIZING THEMES 171
CHAPTER 5 ADDING AND CUSTOMIZING THEMES 171 Exercise 5-2. Use Random Colors for Blocks If you wanted to have each block on the page have a randomly chosen color, this would be a great opportunity to add the logic for choosing the color. Naturally, you could do this directly in the block.tpl.php file, but that would make the file harder to read for your graphic designer, who doesn t care how you determine the color, only that it is available in a nice, clean variable to be applied inside the template. First, add the following _phptemplate_variables function to the template.php file in your theme. If the template.php file doesn t exist, create it (make sure to begin the file with
Now when you access your site, every block should have a border with a randomly chosen color. Manipulations at this point in the code are useful mainly for adding decoration or elements that are external to your site s logic. Most of the page execution code has been run by the time _phptemplate_variables gets called, which means it is quite limited in its possibilities. Furthermore, keep in mind that this is the theme for your site, which, by definition, should concern itself exclusively with visual elements and layout. Nevertheless, for tasks like using random colors for blocks, it is a useful place to make customizations.
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services