Advanced theming
Upcoming SlideShare
Loading in...5
×
 

Advanced theming

on

  • 873 views

 

Statistics

Views

Total Views
873
Slideshare-icon Views on SlideShare
868
Embed Views
5

Actions

Likes
1
Downloads
4
Comments
0

2 Embeds 5

http://drupalcamp.ee 4
http://www.drupalcamp.ee 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Advanced theming Advanced theming Presentation Transcript

    • Drupal Advanced Theming DrupalCamp Estonia Kaido Toomingas 14.June 2012
    • 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
    • Solutions● Lets just put this into templates ;) What does Your designer would say?● What should I do then?● Template.php● Custom module
    • 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()
    • HooksHooks in drupal are functionswich will help you to change orextend default functionality.
    • 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, ); }
    • 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 develmodule switched for using dsm() function dsm($form); // pretty print array using Krumo to messages}
    • 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)) ));
    • hook_theme_registry_alter()● This is the most powerful themer helper wich should be used only when cant 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.