2. Problem
● You need more than Drupal theme can offer you out of box
● You dont need some stuff wich Drupal offers You out of box
3. Solutions
● Lets just put this into templates ;) What does Your designer would
say?
● What should I do then?
● Template.php
● Custom module
4. How can I implement this?
● Hooks? Examples...?
● TEMPLATE_preprocess(&$variables, $hook)
● HOOK_form_alter(&$form, &$form_state, $form_id)
● theme($hook, $variables = array())
● THEMEHOOK_settings() in theme-settings.php
● THEMENAME_form_system_theme_settings_alter(&$form,
$form_state)
● hook_theme_registry_alter()
5. Hooks
Hooks in drupal are functions
wich will help you to change or
extend default functionality.
6. Preprocess
● TEMPLATE_preprocess(&$variables, $hook)
● TEMPLATE_preprocess_HOOK(&$variables)
● Manipulate or create variables. Example page variables. You
can add these into template.php.
Example:
function template_preprocess_foo(&$variables) {
$variables['foo_list'] = array(
'list item 1',
'list item 2',
'list item 3',
);
}
7. Modify forms
● HOOK_form_alter(&$form, &$form_state, $form_id)
● hook_form_FORM_ID_alter
● Change existing form elements by changing or adding
some arrays.
● Create new form elements – There is better way.
Example:
function example_form_alter(&$form, &$form_state, $form_id) {
dsm($form_id); // print form ID to messages You need devel
module switched for using dsm() function
dsm($form); // pretty print array using Krumo to messages
}
8. Theme some data
● theme($hook, $variables = array())
● Usecase: You want to create a table, image or some other element
from you data. You should use theme function for that.
● Usage: Can be used in template.php or custom modules.
Example:
theme('table', array(
'header' => $header,
'rows' => $options,
'attributes' => array('class' => array('mytable'))
));
9. hook_theme_registry_alter()
● This is the most powerful themer helper wich should be used only
when can't find any way to change your theme.
● You can use this when there is module wich doesnt have proper theme
fuctions wich could be overwritten.