11

Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Embed Size (px)

Citation preview

Page 1: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!
Page 2: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Drupal 6 Theme System

• Architecture– Theme Templates– Theme Engines– Theme Hooks

• What’s New– Theme registry– Theme Inheritance– Modules & Themes speak!– Discusssion

• Tips & Tricks– Discussion

Page 3: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Drupal’s Architecture

3 main elements:• Theme Templates• Theme Engines• Hooks

Page 4: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Why Theme Templates?

• Like most CMS’ templates are used to keep design elements separate from processing logic.

• Templates allow flexibility to change your current theme without causing problems in other parts of Drupal.

• Drupal can be updated without breaking your design / theme.

Page 5: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Theme files

When a regular Drupal page is rendered several template files are used:

• Page.tpl• Node.tpl• Block.tpl• Comment.tpl• Template.php (customizations)• Etc…

Page 6: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Theme Engines

What is a theme engine?• Consists of a set of files that handles

rendering data.

What theme engines does Drupal support?• Most common: PHPTemplate• Smarty• XTemplates

Page 7: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Theme Hooks

Like Drupal modules, Themes also use the hook setup to call functions and / or theme related files. Here are some things Drupal does with theme hooks:

• Registering & handling theme files • Searches and loads specified theme files

instead of calling the hook• Modules can use theme hooks to format

data.

Page 8: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

What’s New – Theme Registry

Drupal's theme registry maintains cached data on the available theming hooks and how to handle them.

Learn more about the theme registry and how to override it:

http://drupal.org/node/223463

Page 9: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

What’s New – Theme Inheritance

What is Theme Inheritance?• Is where new themes can draw assets from

other themes, like stylesheets, tpl files, js etc.

Theme inheritance allows great flexibility to make your own theme quickly.

… Also, great for beginners to learn the theme layer.

Page 10: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

What’s New – Modules & Themes

In the new theme system module files can create their own template files and push data to them.

Benefits?• Can skip doing phptemplate_var() in the

template.php file – by pulling tpl files from the module.

• Or, skip overriding files and work in the template.php file with the preprocess function.

• Preprocess function? Friend or Foe?

Page 11: Drupal 6 Theme System Architecture –Theme Templates –Theme Engines –Theme Hooks What’s New –Theme registry –Theme Inheritance –Modules & Themes speak!

Tips & Tricks - Discussion

What are some tricks you use often in the theme layer?

What would you like to do in the theme layer but do not know how or if it is possible?