8. Overriding Templates
Don't hack core templates!
To make a custom node template for a content
type.
- Copy node.tpl.php from /modules/node into your template
directory.
- Rename to node--<type>.tpl.php
9. Overriding Templates
Templates can usually be overridden
hierarchically
page.tpl.php
page--node.tpl.php
page--node--2226.tpl.php
block.tpl.php
block--region.tpl.php
block--module-name.tpl.php
block--module-name-delta.tpl.php
10. template.php
Theme specific overrides.
Either by theme name or rendering engine.
For just this theme:
mytheme_breadcrumb($variables)
For this theme an all sub themes:
phptemplate_breadcrumb($variables)
11. Preprocess Hooks
Alter elements before they are sent to a theme
function or template.
hook_preprocess_html(&$variables)
hook_preprocess_page(&$variables)
hook_preprocess_node(&$variables)
12. Themeing from a Module
hook_theme();
Be nice to your themers!
function hook_theme($existing, $type, $theme, $path) {
return array(
'system_date_time_settings' => array(
'render element' => 'form',
'file' => 'system.admin.inc',
),
);
}
13. Regions
Where blocks go.
In your info file:
regions[header] = 'Header'
In your page.tpl.php template:
<?php print render($page['header_nav']); ?>
17. Tips
Create a subdirectory of templates in your
theme.
If you get stuck turn on the Stark theme to see
the raw HTML being generated.
Think before including JavaScript libraries as
Drupal has a bunch.
18. Tips
When planning a site think about where you
content will go and what blocks go in what
region.
Use $var['theme_hook_suggestions'] in you
preprocess hooks to see what templates are
available.
Use devel themer module to see more
information about what is theming an element.
20. Philip Norton && Mike Bell
Blog
http:///www.norton42.org.uk/
http://www.digital006.com
Twitter
@philipnorton42
@mikebell_
#! code
http://www.hashbangcode.com/
21. Before we forget
What subject next?
Next meetup date is 2nd Jan
- Postpone to week after
- Postpone to month after