power theming

73

Upload: drkdn

Post on 01-Nov-2014

968 views

Category:

Documents


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Power Theming
Page 2: Power Theming

is.gd/3mGND

Page 3: Power Theming
Page 4: Power Theming

Where Drupal gets its markup

Page 5: Power Theming

How to change the markup

Where Drupal gets its markup

Page 6: Power Theming

How to change the markupWorking with subthemes

Where Drupal gets its markup

Page 7: Power Theming

How to change the markupWorking with subthemesTheming forms

Where Drupal gets its markup

Page 8: Power Theming

Color moduleTheme settings

Javascript

Page 9: Power Theming
Page 10: Power Theming

Theme hooks

Page 11: Power Theming

Theme hooks Names or IDs that Drupal uses to call themeable output

Page 12: Power Theming

Theme hooks Names or IDs that Drupal uses to call themeable output*The* theme function

Page 13: Power Theming

Theme hooks Names or IDs that Drupal uses to call themeable output*The* theme function Calls themeable output using theme hooks

Page 14: Power Theming

theme('hook', $arg1, $arg2)

Page 15: Power Theming

Theme registry Stores the "sequence of events" that happens when a theme hook is called

theme('hook', $arg1, $arg2)

Page 16: Power Theming

Defined by implementations of

hook_theme()

Page 17: Power Theming

function node_theme() { return array( 'node' => array( 'arguments' => array( 'node' => NULL, 'teaser' => FALSE, 'page' => FALSE), 'template' => 'node'), 'node_list' => array( 'arguments' => array( 'items' => NULL, 'title' => NULL)));}

Page 18: Power Theming

function node_theme() { return array( 'node' => array( 'arguments' => array( 'node' => NULL, 'teaser' => FALSE, 'page' => FALSE), 'template' => 'node'), 'node_list' => array( 'arguments' => array( 'items' => NULL, 'title' => NULL)));}

theme hooks

Page 19: Power Theming

function node_theme() { return array( 'node' => array( 'arguments' => array( 'node' => NULL, 'teaser' => FALSE, 'page' => FALSE), 'template' => 'node'), 'node_list' => array( 'arguments' => array( 'items' => NULL, 'title' => NULL)));}

this one uses a

template file called node.tpl.p

hp

Page 20: Power Theming

function node_theme() { return array( 'node' => array( 'arguments' => array( 'node' => NULL, 'teaser' => FALSE, 'page' => FALSE), 'template' => 'node'), 'node_list' => array( 'arguments' => array( 'items' => NULL, 'title' => NULL)));}

this one is a function

Page 21: Power Theming
Page 22: Power Theming

theme('node_list', $items, $title)

Page 23: Power Theming

theme('node_list', $items, $title)

Page 24: Power Theming

theme('node_list', $items, $title)

Page 25: Power Theming

theme('node_list', $items, $title)

Page 26: Power Theming

theme('node_list', $items, $title)

Page 27: Power Theming

theme('node', $node, $teaser, $page)

Page 28: Power Theming

theme('node', $node, $teaser, $page)

'template' => 'node'

Page 29: Power Theming

theme('node', $node, $teaser, $page)

node.tpl.php

Page 30: Power Theming

theme('node', $node, $teaser, $page)

Page 31: Power Theming

theme('node', $node, $teaser, $page)

Page 32: Power Theming

theme('node', $node, $teaser, $page)

node-story.tpl.php

Page 33: Power Theming

theme('node', $node, $teaser, $page)

node.tpl.php

Page 34: Power Theming

drupal.org/node/173880

Page 35: Power Theming

Let Drupal know you've added oroverridden a new theme hook with

drupal_rebuild_theme_registry()

Page 36: Power Theming

Allows you to create theme stacksor a theme hierarchy

Page 37: Power Theming

Subthemes inherit from parent themes:

Page 38: Power Theming

Subthemes inherit from parent themes:

Stylesheets

Page 39: Power Theming

Subthemes inherit from parent themes:

StylesheetsJavascript

Page 40: Power Theming

Subthemes inherit from parent themes:

StylesheetsJavascriptTheme functions/overrides

Page 41: Power Theming

Subthemes inherit from parent themes:

StylesheetsJavascriptTheme functions/overridesTheme templates

Page 42: Power Theming

Subthemes inherit from parent themes:

StylesheetsJavascriptTheme functions/overridesTheme templatesPreprocessors

Page 43: Power Theming

Subthemes inherit from parent themes:

StylesheetsJavascriptTheme functions/overridesTheme templatesPreprocessors

Subthemes do *not* inherit regions

Page 44: Power Theming

Benefits of subtheming

Page 45: Power Theming

Benefits of subthemingEliminate redundant coding for every site

Page 46: Power Theming

Benefits of subthemingEliminate redundant coding for every siteDevelop themes quicker

Page 47: Power Theming

Benefits of subthemingEliminate redundant coding for every siteDevelop themes quickerContent separate from "skin"

Page 48: Power Theming

Benefits of subthemingEliminate redundant coding for every siteDevelop themes quickerContent separate from "skin"Multisite themes can share a base theme

Page 49: Power Theming

Benefits of subthemingEliminate redundant coding for every siteDevelop themes quickerContent separate from "skin"Multisite themes can share a base themeCan make modular theme "pieces"

Page 50: Power Theming

In the .info file:

base theme = name

Daisy chain your themes and let the inheritance begin

Page 51: Power Theming

.info file

Page 52: Power Theming

global $theme_info

Page 53: Power Theming

global $theme_info Properties of the current theme

Page 54: Power Theming

global $theme_info Properties of the current theme

global $base_theme_info

Page 55: Power Theming

global $theme_info Properties of the current theme

global $base_theme_info Properties of the base theme

Page 56: Power Theming

global $theme_info Properties of the current theme

global $base_theme_info Properties of the base theme

list_themes()

Page 57: Power Theming

global $theme_info Properties of the current theme

global $base_theme_info Properties of the base theme

list_themes() Properties of all themes

Page 58: Power Theming

global $theme_key

Page 59: Power Theming

global $theme_key Name of the current theme

Page 60: Power Theming

global $theme_key Name of the current theme (i.e. key in the list_themes() array)

Page 61: Power Theming

global $theme_path

global $theme_key Name of the current theme (i.e. key in the list_themes() array)

Page 62: Power Theming

global $theme_path Path to the current theme

global $theme_key Name of the current theme (i.e. key in the list_themes() array)

Page 63: Power Theming

Universally theming forms

Page 64: Power Theming

Universally theming forms All form-related theme functions are in includes/form.inc

Page 65: Power Theming

Theming specific forms

Universally theming forms All form-related theme functions are in includes/form.inc

Page 66: Power Theming

Theming specific forms Inject markup into forms using the Form API

Universally theming forms All form-related theme functions are in includes/form.inc

Page 67: Power Theming

function example_theme() { return array( 'user_login' => array( 'arguments' => array('form' => NULL), ), );}

Implement hook_theme()

Page 68: Power Theming

function example_theme() { return array( 'user_login' => array( 'arguments' => array('form' => NULL), ), );}

Implement hook_theme()

Page 69: Power Theming

<input type="hidden" name="form_id" id="edit-user-login" value="user_login" />

Get the form_id

Page 70: Power Theming

function example_user_login($form) {

// Change the form array here

return drupal_render($form);}

Create theme function

Page 71: Power Theming

Add markup around elements #prefix #suffix

Page 72: Power Theming

Add markup around elements #prefix #suffix

Add or change element's attributes #attributes

Page 73: Power Theming

api.drupal.org

Themer developer module (part of Devel)

Drupal 6 JavaScript and jQuery by Matt Butcher

The Internet