Archive for April, 2007

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 155 (Personal web server)

Thursday, April 26th, 2007

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 155 Configure your theme by going to administer . themes and clicking the Configure tab (admin/themes/settings). See Chapter 2 for a complete discussion on how to configure a theme, including setting the primary and secondary links, toggling post information, and so on. Your theme is now installed and configured. To uninstall a theme, deactivate it from administer . themes (admin/themes) and remove it from the themesdirectory. Customizing Themes It is very convenient that Drupal offers so many nice-looking themes. Having a functional site that looks nice without needing to do any work is a great luxury, especially if your site s appearance isn t your main focus. However, most people will want their sites to have a unique look to them something that sets the site apart from others and contributes to the site s identity. Learning to customize existing themes or make new ones will greatly add to the quality of your Drupal experience. The most common way to theme a Drupal site is to start with an existing theme and add your own elements. By testing several existing themes and choosing the one that brings you closest to your goals, you often save hours of work. You won t need to worry about the basics, such as deciding how many columns to use, whether the design should be fixed width or flexible, the size of the header, and so on. By modifying an existing theme, you can work incrementally, changing one element at a time, slowly morphing it into an original creation. Many of the trickier problems will have already been solved by the theme s original author. On the other hand, a finished theme is often an intricate web of templates and style sheet information. If you find yourself spending a lot of time stripping away other people s ideas and longing for a clean slate, starting from scratch is not difficult and gives you the greatest control over your theme. Whether you decide to modify an existing theme or make your own, a good understanding of how themable functions and templates work will be necessary, especially if you intend to modify the HTML that is being output. Introducing Themable Functions The HTML output that is generated by Drupal has been carefully crafted to be accessible, lightweight, and easily styled with CSS. Despite this, you may find yourself wanting to change the HTML output in some way. Drupal takes great care to make this possible without forcing you to change the source code of the core files and modules. Instead, all HTML that is output comes from themable functions that can be overwritten from within individual themes. The role of the theme is to provide alternate versions of themable functions for the cases where different output is desired. Keeping these changes at the theme level, rather than needing to hack core files and modules, is a great advantage when it comes to upgrading Drupal to a new version, as it saves you from hunting down all the changes in the old version and reimplementing them in the new version. It is also necessary if you intend to host multiple sites from one codebase, a topic covered in Chapter 6. You can identify themable functions in the core includes and modules by their name, which starts with theme_. This naming convention allows Drupal to identify the function s role
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

154 CHAPTER 5 ADDING AND (Make my own web site) CUSTOMIZING THEMES

Wednesday, April 25th, 2007

154 CHAPTER 5 ADDING AND CUSTOMIZING THEMES Figure 5-5. Directory structure of the core themes Installing New Themes You can find many themes available for download at Drupal.org (http://drupal.org/project/ Themes). Installing them is a simple process, but you need to make sure that you have the necessary theme engine installed. This should always be clear from the theme s description on Drupal.org, but is often overlooked. If you do not have the proper theme engine (as determined by taking a peek in your themes/engines directory), locate and download the theme engine first (from http://drupal.org/project/Theme%20engines). Caution Make sure that the version number of your theme, theme engine, and Drupal installation match. Version 4.7 themes are only guaranteed to work on Drupal 4.7 with a version 4.7 theme engine. After downloading a theme, unpack it and move the unpacked folder to the themesdirectory. The name of the unpacked directory is the name of the theme. Navigate to administer . themes (admin/themes), and you will see the theme listed. Activate the theme, and determine whether it is to be the main theme for the site. If not, you can activate it for your user account from your account page (my account).
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision php5 hosting services

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 153 (Web server certificate)

Wednesday, April 25th, 2007

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 153 How Drupal Finds Themes Whenever you visit the theme administration page (admin/themes), Drupal looks to see which themes are available and lists them for you. This is a four-step process, which is important to be aware of if you are interested in modifying existing themes or making new themes: 1. Drupal looks for pure themes like Chameleon by searching for subdirectories of themes that contain a name.themefile. It expects that the name of the theme will match the directory in which it is found, so chameleon.themeshould be found in the themes/chameleon folder, for example. Each pure theme is added to the list of themes. 2. Drupal determines which engines are available by looking for files with the .engine suffix in subdirectories of the themes/engines directory. These engines are given the responsibility of determining which templates fall under their control. A list of theme engines is made. 3. Drupal asks each engine to identify themes belonging to it. PHPTemplate accomplishes this by looking for subdirectories of themes that have a page.tpl.php file in them. The presence of this file is the only requirement of a PHPTemplate theme, and you could conceivably make a theme with nothing but page.tpl.php. Each theme engine then returns a list of themes under its control, and these are added to the list of themes. 4. Finally, there are CSS-only themes, called styles, which consist of nothing but a style sheet that is applied to an existing template or theme. For this, Drupal looks for files called style.css in subdirectories of known themes. Each style.css that is found behaves as an alternate style sheet that is applied to the HTML of the parent theme (in whose folder it resides). The list of styles is then added to the list of themes, which is now complete. Table 5-1 shows the makeup of the default themes. Table 5-1. Components of the Core Themes Theme Engine Templates CSS Bluemarine Pushbutton phptemplate.engine *.tpl.php themes/bluemarine/style.css themes/pushbutton/styles.css Chameleon Marvin chameleon.theme chameleon.theme themes/chameleon/style.css themes/chameleon/marvin/style.css Figure 5-5 shows all of the theme-related files that are delivered with Drupal and their relationships based on Table 5-1. You will notice how the Marvin style exists as a subdirectory in the Chameleon theme and consists of only a style sheet. This figure also shows the default *.tpl.php template files in the phptemplate directory. These templates affect all PHPTemplate themes, unless they are specifically overridden within the themes themselves. Details on overriding templates and creating CSS-only themes (styles) are provided in the Customizing Themes section later in this chapter.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision j2ee hosting services

152 CHAPTER 5 ADDING AND CUSTOMIZING THEMES (Photography web hosting)

Tuesday, April 24th, 2007

152 CHAPTER 5 ADDING AND CUSTOMIZING THEMES Theme Components The three main components of any theme are the engine, the templates, and the CSS style sheet. The theme engine receives requests from Drupal to translate pure content into themed output and directs these requests to the appropriate template, which then does the translation into HTML. The style sheet then gives the HTML its look and feel. The theme engine also has the role of managing any theme-specific settings that core Drupal is unaware of. You can see these settings by selecting administer . themes and clicking the Configure tab (admin/themes/settings). In the Toggle Display section, you ll see settings that usually include items such as the site name, site slogan, primary links, and secondary links, with the choice of turning these settings on and off. You can see the differences between themes by comparing the list of features for the Blue- marine theme (admin/themes/settings/bluemarine) and the Chameleon theme (admin/themes/ settings/chameleon). Bluemarine has a larger set of features than Chameleon because it is based on a different theme engine, which is more fully implemented. Bluemarine is run by the PHPTemplate engine, and Chameleon has its own engine. Templates take pure content from Drupal and decorate it with the HTML necessary for display in the site. Since a system like Drupal is rather complex, it is not generally easy, or even possible, to achieve this task without making some decisions along the way. For example, when rendering a blog post, the result will be different depending on whether the teaser view or the full view is requested. This type of decision is made in the template and is the reason why most templates require both HTML and PHP code (for the presentation logic). Bluemarine is the name of a template that runs on the PHPTemplate engine. The files in the themes/bluemarine folder are the template files, and they depend on the engine to func tion. Without the files in templates/engines/phptemplate, Bluemarine would not even be recognized by Drupal as being a theme. On the other hand, Chameleon is both a theme engine and a template at once. More accurately, when Chameleon was first written, the distinction between these two parts hadn t been as clearly delineated. Chameleon is included in Drupal mostly for historical and demon stration purposes and is known as a pure theme (meaning it handles theme calls directly in PHP without delegating them to a template or relying on an external engine). It demonstrates the essence of what a theme is and can be used and extended comfortably, but it lacks a cer tain flexibility, especially when it comes to reusing components across several themes. The shortcomings of themes like Chameleon are the reason PHPTemplate was created. PHPTemplate, the theme engine, provides a comfortable and high-performance way to design theme elements that are easy to work with, modular, and reusable. It is now the standard method for theming Drupal sites, and this chapter will focus exclusively on theming with PHPTemplate. Note The theme engine determines the templating language that is to be used by the theme. Engines can be written to support virtually any templating language. The standard theme engine for Drupal is PHPTemplate. Other common possibilities include Smarty, PHPTal, and XTemplate. To see which engines are available, visit http://drupal.org/project/Theme%20engines. For more information about the composition of themes, see http://drupal.org/node/11774.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

CHAPTER 5 ADDING AND (Web site layout) CUSTOMIZING THEMES 151

Tuesday, April 24th, 2007

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 151 Figure 5-3. Rdc theme Figure 5-4. Pastorale theme
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Tomcat web server - CHAPTER 5 ADDING AND CUSTOMIZING THEMES 150

Monday, April 23rd, 2007

CHAPTER 5 ADDING AND CUSTOMIZING THEMES 150 Figure 5-1. Green Marin e theme Figure 5-2. Occy theme
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision mysql5 web hosting services

Adding and Customizing Themes CHAPTER 5 (Com web hosting)

Monday, April 23rd, 2007

Adding and Customizing Themes CHAPTER 5 Drupal themes are the place where the worlds of graphic artists and programmers meet. A theme is a collection of files that defines the structure, style, and, to an extent, the behavior of your site. Themes use HTML code for the structure, CSS and images for the style, and PHP for determining behavior to give your site its look and feel. Drupal has four themes as examples in the core distribution, and Drupal.org offers a number of contributed themes, ranging from completely finished solutions that are ready to be installed and used to those intended as clean starting points for your design efforts. This chapter will show you how to download and install new themes. You will then see what components come together to be a theme, what template files look like and how they work, and how you can override themable functions to change the HTML that is being generated by your site. You will also learn how to create your own template files and how to make entire themes that are based on only CSS. Finally, I will recommend some modules that are helpful when theming a site. Understanding Themes Themes have two main responsibilities: providing the CSS and image files that are involved with your site s visual design and, if needed, overriding the default HTML output that is generated by Drupal s core files and modules. When customizing the look of your site, most of the work will be done at the CSS level, and this is therefore the theme s most important task. You can get an overview of your installed themes by navigating to administer . themes (admin/themes). The four themes that come with the Drupal core distribution are Bluemarine, Pushbutton, Chameleon, and Marvin. The contributed themes repository on Drupal.org (http://drupal.org/project/Themes) is a great source for attractive and interesting themes. Figures 5-1 through 5-4 illustrate several different contributed themes showing the same content. At this level, the concept of a theme is clear. It is a look and feel for a site that the administrator can activate. Themes are a tool for keeping the separation between content and appearance clean. Content is stored in the database, and the theme decides how to present it.
Note: In case you are looking for affordable webhost to host and run your web application check Vision http web server services

Tomcat web server - CHAPTER 4 ADDING CONTRIBUTED MODULES 147 Summary

Sunday, April 22nd, 2007

CHAPTER 4 ADDING CONTRIBUTED MODULES 147 Summary The repository of contributed Drupal modules is vast and diverse in scope. Installing and configuring Drupal modules tends to follow a common pattern that includes moving files into the modules folder on the web server, possibly updating the database schema, and enabling the module from the admin/modulesscreen. Modules usually have a settings page, which can be accessed via administer . settings. In this chapter, you learned how to install, configure, and use some useful modules: TinyMCE, Image, Image Assist, Flexinode, Event, Location, Organic Groups, Spam, Database Administration, and Devel. In this and the previous chapters, you ve learned how Drupal sites work and what you can do with them. In the next chapter, you will dive into the world of theming your Drupal site so that you can control how every element looks and make your site a visual masterpiece. Based on an abstract theme layer, Drupal s theme system allows you to access and control the HTML that is created without needing to modify the source code for modules or core files. This is not only good software architecture, but it also opens the door for sophisticated usage such as running multiple sites (each with their own theme) off a common codebase. Running multiple Drupal sites is covered in Chapter 6.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services

Web hosting company - 146 CHAPTER 4 ADDING CONTRIBUTED MODULES Figure

Sunday, April 22nd, 2007

146 CHAPTER 4 ADDING CONTRIBUTED MODULES Figure 4-20. The page timer and query log Using Developer Functions If you are writing code for Drupal, the following four functions can help you while you work: dprint($str): Works like the PHP function print( string arg )function (http:// php.net/print) but inside

 tags.    dprint_r($arr): Works like the PHP function bool print_r ( mixed expression  [, bool return] ) (http://php.net/print_r ) but inside
 tags.    ddebug_backtrace(): Works like the PHP function array debug_backtrace ( void )  (http://php.net/debug_backtrace) but inside
 tags.    devel_variable(): Outputs the global Drupal configuration variables array $config.  You can add these functions to the source code files or to text areas that are evaluated as  PHP with the PHP filter as tools for debugging.   Emptying the Cache   Something that every new Drupal developer learns is that the cache table in the database  can be emptied without ill effect to the integrity of the database or its data. In fact, when  you re programming certain elements, such as the hook_menu function for a module, it is  necessary to empty the cache from time to time. When developing Drupal, especially when  making changes to the hook_menu function of a module or when dealing with filtered text,  you usually need to clear the cache before your changes will become visible. Menus, variables, and other key elements are cached to improve the performance of the page-building  process.   The Devel module offers a convenient link for developers so that they don t need to keep   running database queries manually to clear the cache. With the Devel module enabled, an   Empty cache link appears in the main navigation menu (devel/cache/clear).    Note There is almost no reason to clear the cache if you are not developing Drupal modules. But if you  accidentally clear the cache, don t worry you haven t hurt anything.   
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

CHAPTER 4 ADDING CONTRIBUTED (Java web server) MODULES 145 xdebug.auto_profile=1

Saturday, April 21st, 2007

CHAPTER 4 ADDING CONTRIBUTED MODULES 145 xdebug.auto_profile=1 xdebug.auto_profile_mode=3 xdebug.output_dir=’/php’ xdebug.default_enable=1 For .htaccess, add this: php_value xdebug.auto_profile=1 php_value xdebug.auto_profile_mode=3 php_value xdebug.output_dir=’/php’ php_value xdebug.default_enable=1 Configuring the Devel Module To configure the Devel module, set its one permission and adjust its settings for the page timer and query log, if desired. Devel Module Permissions The Devel module defines one user permission, Access Devel Information, which should be enabled for any roles that are to be involved in development or optimization of the site. Only users with this permission will see the page timer and query log when they are turned on, as described next. Page Timer and Query Log To configure the Devel module, navigate to administer . settings . devel (admin/settings/ devel). The settings page has options for enabling the page timer and the query log. The information they generate will be visible to users with the Access Devel Information permission. The Query Execution Threshold field is the threshold in milliseconds for queries to be considered slow. Queries that exceed this threshold or execute more than once will be highlighted in the query log that appears at the bottom of each screen (when this log is turned on). You can adjust this threshold to give you the most meaningful data. In many cases, Drupal will perform a set of queries and actions, only to redirect you to a screen or path other than the one you requested. A classic example of this is the 404 Not Found screen. For example, you request the page for node/4711, but there is no node with that ID, so Drupal tells you it can t find it. The problem this presents for debugging is that the SQL queries for the first part of the operation the part where Drupal looks up 4711 and doesn t find anything are not included in the query log because of the redirection that occurs thereafter. The Display Redirection Page field takes care of this problem by alerting you when a redirect is about to occur and waiting for your input before the redirect is carried out. This gives you the chance to inspect the queries that occur prior to the redirection as well as after. Viewing Timer and Query Log Information Using the page timer and query log is a simple matter of browsing your site with them enabled and enjoying the bounty of information that they produce. Figure 4-20 shows an excerpt from a timer and query log.
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services