Web server logs - 160 CHAPTER 5 ADDING AND CUSTOMIZING THEMES
160 CHAPTER 5 ADDING AND CUSTOMIZING THEMES HTML code without needing to worry about escaping quotation marks or concatenating strings a fact that greatly improves the readability of template files over PHP functions that do the same thing. PHP Code and Templates If you are a web designer and you ve been given the task of creating a Drupal theme, you need not be scared of the fact that the templates mix PHP and HTML code. Even if you ve never programmed PHP before, the amount of skill and knowledge needed to work with the themes is small enough that you will be able to learn it quickly. Here are some examples of what you might see and explanations of what they do. The first is a simple printconstruct: This construct prints the contents of a variable (sends the contents to the browser for display on the screen). In this case, the variable $picture is being printed. The tags identify the parts that are to be interpreted as PHP and keep the PHP separate from the rest of the template. Here is a conditional print construct: This is a more elaborate version of the first example, which uses the ? and : to make a decision. In this case, it can be read if $sticky is set, print the text sticky; otherwise, print nothing (”"). The following uses if to make a decision:
In this example, the first line asks is $picture true? If so, the text
will be printed. Note that the opening if statement must be closed by a corresponding endif statement. Finally, this code creates a list:
This example shows how to build an unordered list
- with a variable number of list items
- . It takes the variable $primary_links, which is an array, and uses the foreach operator to go over the array one item at a time, pointing the variable $link to the current item. For each primary link, an
- element with the link s contents is printed. Notice the endforeach tag, which is needed to close the foreach tag.
Note: In case you are looking for affordable webhost to host and run your web application check Vision cheap hosting services