Drupal 7

July 21, 2016 | Author: firoud | Category: Types, Instruction manuals
Share Embed Donate


Short Description

How to create a Drupal theme...

Description

Drupal Theming Guide Abderrahman Firoud

About theming   

Drupal version: Drupal 6.x, Drupal 7.x Audience: Themers Last modified: May 9, 2011

You can do more with a theme than change the appearance of an entire site. It is also possible to "theme" only certain sections of a site, select types of content, or even individual pages. For example, your theme could specify a different look for just the front page of your site. Some other things you may not know that you can do with a theme are:     

Change layouts, images or fonts Hide or display fields dependent on user role Dynamically respond to changes in the content or to user input Modify or replace text (for example the labels) and variables generated by modules It's also possible to port open source designs between other systems (Joomla! templates, WordPress themes, etc.) and Drupal, or convert any website layout or template into a Drupal theme

2

Theming Drupal 6 and 7 There were several changes in the theme system between Drupal 6 and 7. This guide contains information on both. The default theme for Drupal 7 is Bartik, and for Drupal 6 is Garland. Please note: Not all information has been updated for Drupal 7, but more information is continually being added about Drupal 7 theming.

3

How the Drupal theme system works Pages in this section describe the way the Drupal theme system operates, theme components and settings, .info files and page templates. This section is a starting point for creating a new custom theme.       

Overview of theme files Structure of the .info file Default .info values Assigning content to regions Theme settings Clearing the theme cache Creating a sub-theme

4

Overview of theme files A theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a theme. Only the .info file is required, but most themes and sub-themes will use other files as well. The following diagram illustrates the files that are found in a typical theme and sub-theme.

Drupal 6

5

Drupal 7

.info (required) All that is required for Drupal to see your theme is a ".info" file. Should the theme require them, meta data, style sheets, JavaScripts, block regions and more can be defined here. Everything else is optional. The internal name of the theme is also derived from this file. For example, if it is named "drop.info", then Drupal will see the name of the theme as "drop". Drupal 5 and below used the name of the enclosing folder of the theme. Info files for themes are new in Drupal 6. In version 5, .info files were used solely for modules. template files (.tpl.php)

6

These templates are used for the (x)HTML markup and PHP variables. In some situations they may output other types of data --xml rss for example. Each .tpl.php file handles the output of a specific themable chunk of data, and in some situations it can handle multiple .tpl.php files through suggestions. They are optional, and if none exists in your theme it will fall back to the default output. Refrain from having complex logic in these files. In most cases, it should be straight (x)HTML tags and PHP variables. A handful of these templates exist in directories where core and contributed modules exist. Copying them to your theme folder will force Drupal to read your version. Note: The theme registry caches information about the available theming data. You must reset it when adding or removing template files or theme functions from your theme. template.php For all the conditional logic and data processing of the output, there is the template.php file. It is not required, but to keep the .tpl.php files tidy it can be used to hold preprocessors for generating variables before they are merged with the markup inside .tpl.php files. Custom functions, overriding theme functions or any other customization of the raw output should also be done here. This file must start with a PHP opening tag "
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF