172 CHAPTER 5 ADDING (Photoshop web design) AND CUSTOMIZING THEMES

172 CHAPTER 5 ADDING AND CUSTOMIZING THEMES Overriding Themable Functions The preceding section demonstrated how to work with the default tpl.phpfiles to modify your theme. Each of these files represents an override to a themable function from the Drupal core. While theme_page, theme_node, theme_comment, theme_box, and theme_block may be the most important themable functions, and thus have the greatest and most direct impact on the appearance of your site, they are by no means the only functions that are available for modification. Core Drupal includes dozens more themable functions, and most contributed modules add to the list as well. Learning how to find and override any themable function you wish is essential to having full mastery over your Drupal site. How to Find Themable Functions Finding themable functions, at the most basic level, is easy. You just open the code and search for function theme_. Everything that turns up is a themable function and can be overridden. This isn t much consolation, however, when you are looking at your site and you want to change a particular HTML snippet in a particular way. How do you know which themable function is responsible for a given widget or element in your Drupal site? Unfortunately, Drupal doesn t provide an easy built-in method for doing this. However, there is an easy way to fix this, and doing so gives you a good opportunity to peer further into the world of Drupal theming. Exercise 5-3 gives you a tool for identifying themable functions. Exercise 5-3. Identify Themable Functions The goal of this exercise is to modify the function responsible for calling themable functions in such a way that allows you to see in the HTML output which function was called. To do this, you will wrap the output from each call to a themable function in HTML comments like this: result of the themable function This way, you can look at the source code of a generated page and know exactly which themable function to override in order to change the output. This will be a handy tool while designing the theme for your site, but you won t want to use it on a production site. To begin, locate the includes/theme.inc file and make a backup copy, which you will use later to restore your Drupal installation to its original state when you re finished with this exercise. In theme.inc, find the theme() function around line 160. This is the function that is responsible for determining exactly which themable function to call. It looks first for a function specific to your theme, then to the theme engine, and finally to the default theme_foo function, calling the first one found. Replace the theme() function with the following code: function theme() { global $theme, $theme_engine; if ($theme === NULL) { // Initialize the enabled theme. $theme = init_theme(); }
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