a presentation by Geoffrey Roberts
Thursday, 17th March 2011
Relies on overriding and inheritance
function theme_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'.
implode(' » ', $breadcrumb).'</div>';
}}
function my_theme_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'.
theme('item_list', $breadcrumb).'</div>';
}
}
Can be extended: don't need to stand alone
Theme developers: you don't need to do all the work
If I have seen a little further it is by standing on the shoulders of Giants.
Isaac Newton
Follows the same principles of overriding and inheritance
Sub themes are to base themes
as
Modules are to Drupal core
Subtheming does require coding skill (HTML /CSS/PHP)
A lot of good base themes come with documentation on creating subthemes
eg. Zen, Basic
Readme usually contains helpful info
Some base themes come with a starterkit directory or an example directory
Your subtheme will be named after your theme's directory
To create a subtheme, add the line
base theme = othertheme
Your base theme can be in any themes directory you like
A base theme can define its own stylesheets and scripts
Subthemes can either inherit, override or disable any of these
Do nothing: stylesheet will automatically be added
// basetheme style.css
p {
font-size: 14px;
}
Use a stylesheet with the same relative path
// yourtheme style.css
p {
font-size: 14px;
color: red;
}
Override with an empty file
// yourtheme style.css
Theming functions for your template start with the name of your subtheme
Note: If you started with a starterkit, don't forget to rename functions
eg. basic_preprocess_page becomes yourtheme_preprocess_page
Subthemes inherit theming functions in template.php from their base theme
Subthemes inherit template files from base theme
Subthemes inherit screenshots
Subthemes do not inherit logos
Subthemes do not inherit regions
They must be declared in the .info file
Subthemes do not inherit colours or advanced settings that the base theme declares