Theme API
 Rolf van de Krol
Drupal 7.2 - default install
          bartik
      views & devel
includes/theme.inc
$html = theme(
  'item_list',
  array(
    'items' => $links,
    'title' => t('My links')
  )
);
$html = theme(
  'item_list',
  array(
    'items' => $links,
    'title' => t('My links')
  )
);
$html = theme(
  'item_list',
  $links,
  t(‘My links’)
);


$html = theme(
  'item_list',
  array(
    'items' => $links,
    'title' => t('My links')
  )
);
$html = theme(
  'item_list',
  $links,
  t(‘My links’)
);


$html = theme(
  'item_list',
  array(
    'items' => $links,
    'title' => t('My links')
  )
);
‘theme’ initialization

          ‘theme registry’ loading

      finding of callable ‘theme hook’

         including of required files

  handle some ‘render array’ specific stuff

  merging the defaults into the ‘variables’

  getting information from the ‘base hook’

executing ‘preproces’ and ‘process’ functions

   handling of ‘theme hook suggestions’

executing ‘function’ or rendering ‘template’
‘theme’ initialization

          ‘theme registry’ loading

      finding of callable ‘theme hook’

         including of required files

  handle some ‘render array’ specific stuff

  merging the defaults into the ‘variables’

  getting information from the ‘base hook’

executing ‘preproces’ and ‘process’ functions

   handling of ‘theme hook suggestions’

executing ‘function’ or rendering ‘template’
theme
registry
theme
registry


           theme($hook,
              $vars)
hook_theme
hook_theme_alter



                    theme
                   registry


                              theme($hook,
                                 $vars)
'item_list' => array(
  'variables' => array(
    'items' => array(),
    'title' => NULL,
    'type' => 'ul',
    'attributes' => array(),
  ),
  'type' => 'module',
  'theme path' => 'modules/system',
  'function' => 'theme_item_list',
);
'page' => array(
  'template' => 'page',
  'path' => 'themes/bartik/templates',
  'type' => 'theme_engine',
  'theme path' => 'themes/bartik',
  'render element' => 'page',
  'preprocess functions' => array(
    'template_preprocess',
    'template_preprocess_page',
    'contextual_preprocess',
    'overlay_preprocess_page',
    'shortcut_preprocess_page',
  ),
  'process functions' => array(
    'template_process',
    'template_process_page',
    'rdf_process',
    'bartik_process_page',
  ),
);
devel module
        http://drupal.org/project/devel

http://mydrupalinstall.com/devel/theme/registry
Building registry
  hook_theme
hook_theme_alter
hook_theme
hook_theme_alter




                    Building registry
  system_theme
   node_theme
phptemplate_theme
   stark_theme
 mytheme_theme
hook_theme
hook_theme_alter




                    Building registry
  system_theme
   node_theme
phptemplate_theme
   stark_theme
 mytheme_theme
theme




                Building registry
base theme(s)


    modules
Building registry
Building registry
PHPTemplate




Building registry
PHPTemplate




                 Building registry
Inspects theme
Inspects theme




                    Building registry
Find templates
and functions
mytheme.theme




Building registry
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

 find ‘base themes’

  register CSS files

  register JS files




                                    Using registry
include template.php
initialize themes

 find ‘base themes’

  register CSS files

  register JS files




                                                   Using registry
include template.php                theme engine
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
get callable theme hook




$html = theme(
  ‘views_view’,
  array(




                                     Using registry
    ‘view’ => $this->view,
    ‘options’ => $this->options,
    ‘rows’ => $rows
  )
);
get callable theme hook




$html = theme(
  ‘views_view’,
  array(




                                     Using registry
    ‘view’ => $this->view,
    ‘options’ => $this->options,
    ‘rows’ => $rows
  )
);
get callable theme hook


$html = theme(
  array(
    ‘views_view__myviewname’,
    ‘views_view’
  ),




                                     Using registry
  array(
    ‘view’ => $this->view,
    ‘options’ => $this->options,
    ‘rows’ => $rows
  )
);
get callable theme hook


$html = theme(
  array(




                               ns
    ‘views_view__myviewname’,




                            tio
    ‘views_view’




                         es
  ),




                       gg




                                     Using registry
                    su
  array(
                ok
    ‘view’ => $this->view,
              ho
    ‘options’ => $this->options,
             e

    ‘rows’ => $rows
         em




  )
        th




);
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
include files



‘status_report’ => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
  'type' => 'module',




                                         Using registry
  'theme path' => 'modules/system',
  'function' => 'theme_status_report',
  'includes' => array(
    'modules/system/system.admin.inc',
  ),
),
include files



‘status_report’ => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
  'type' => 'module',




                                         Using registry
  'theme path' => 'modules/system',
  'function' => 'theme_status_report',
  'includes' => array(
    'modules/system/system.admin.inc',
  ),
),
include files
‘status_report’ => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
  'type' => 'module',
  'theme path' => 'modules/system',




                                         Building registry
  'function' => 'theme_status_report',
  'includes' => array(
    'modules/system/system.admin.inc',
  ),
),
'status_report' => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
),
include files
‘status_report’ => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
  'type' => 'module',
  'theme path' => 'modules/system',




                                         Building registry
  'function' => 'theme_status_report',
  'includes' => array(
    'modules/system/system.admin.inc',
  ),
),
'status_report' => array(
  'render element' => 'requirements',
  'file' => 'system.admin.inc',
),
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
handle render array




$elements = array(




                                     Using registry
  '#type' => 'textfield',
  '#title' => t('My title'),
);
handle render array




$elements = array(
  '#type' => 'textfield',




                                     Using registry
  '#title' => t('My title'),
);
$html = drupal_render($elements);
handle render array
$elements = array(
  '#type' => 'textfield',
  '#title' => t('My title'),
);
$html = drupal_render($elements);




                                      Using registry
<div class="form-item form-type-
textfield">
 <label>My title</label>
 <input type="text" maxlength="128"
   size="60" class="form-text" />
</div>
handle render array




                                 Using registry
hook_element_info
handle render array

hook_element_info
array(
  '#input' => TRUE,
  '#size' => 60,
  '#maxlength' => 128,
  '#autocomplete_path' => FALSE,




                                   Using registry
  '#process' => array(
    'ajax_process_form'
  ),
  '#theme' => 'textfield',
  '#theme_wrappers' => array(
    'form_element'
  ),
);
handle render array
$elements = array(
 '#type' => 'textfield',
 '#title' => 'Shizzle',
 '#input' => TRUE,
 '#size' => 60,
 '#maxlength' => 128,




                                  Using registry
 '#autocomplete_path' => FALSE,
 '#process' => array(
   'ajax_process_form',
 ),
 '#theme' => 'textfield',
 '#theme_wrappers' => array(
   'form_element',
 ),
handle render array
$elements = array(
 '#type' => 'textfield',
 '#title' => 'Shizzle',
 '#input' => TRUE,
 '#size' => 60,
 '#maxlength' => 128,




                                  Using registry
 '#autocomplete_path' => FALSE,
 '#process' => array(
   'ajax_process_form',
 ),
 '#theme' => 'textfield',
 '#theme_wrappers' => array(
   'form_element',
 ),
handle render array




                                   Building registry
'textfield' => array(
  'render element' => 'element',
),
handle render array




'textfield' => array(
  'render element' => 'element',




                                   Using registry
),
$variables = array(
  ‘element’ => $elements
);
handle render array




                                  Using registry
   The Scary Render Array
Erik Stielstra - today at 15:15
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
get defaults for variables




$html = theme(
  'item_list',
  array(




                                            Using registry
    'items' => $links,
    'title' => t('My links')
  )
);
get defaults for variables




$html = theme(
  'item_list',
  array(




                                            Using registry
    'items' => $links,
    'title' => t('My links')
  )
);
get defaults for variables

$html = theme(
  'item_list',
  array(
    'items' => $links,
    'title' => t('My links')
  )




                                           Using registry
);
'item_list' => array(
  'variables' => array(
    'items' => array(),
    'title' => NULL,
    'type' => 'ul',
    'attributes' => array()
  ),
),
get defaults for variables




array(
  'items' => $links,




                                            Using registry
  'title' => t('My links'),
  'type' => 'ul',
  'attributes' => array()
)
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
execute preprocess and process functions


$variables




                                                Using registry
                              preprocess


                                 process
execute preprocess and process functions
array(
  'template' => 'page',
  'path' => 'themes/bartik/templates',
  'type' => 'theme_engine',
  'theme path' => 'themes/bartik',
  'render element' => 'page',
  'preprocess functions' => array(
    'template_preprocess',




                                                 Using registry
    'template_preprocess_page',
    'contextual_preprocess',
    'overlay_preprocess_page',
    'shortcut_preprocess_page',
  ),
  'process functions' => array(
    'template_process',
    'template_process_page',
    'rdf_process',
    'bartik_process_page',
  ),
)
execute preprocess and process functions
array(
  'template' => 'page',
  'path' => 'themes/bartik/templates',
  'type' => 'theme_engine',
  'theme path' => 'themes/bartik',
  'render element' => 'page',
  'preprocess functions' => array(
    'template_preprocess',




                                                 Using registry
    'template_preprocess_page',
    'contextual_preprocess',
    'overlay_preprocess_page',
    'shortcut_preprocess_page',
  ),
  'process functions' => array(
    'template_process',
    'template_process_page',
    'rdf_process',
    'bartik_process_page',
  ),
)
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
handle base hook

    handle theme hook suggestions



          views_view_field
views_view_field__archive__page__title




                                        Using registry
               node
            node__page

               region
          region__sidebar
handle base hook

handle theme hook suggestions




                                Building registry
         pattern
handle base hook

        handle theme hook suggestions




                 pattern




                                        Building registry
'node' => array(
  'render element' => 'elements',
  'template' => 'node',
),
handle base hook

        handle theme hook suggestions


                 pattern




                                        Building registry
'node' => array(
  'render element' => 'elements',
  'template' => 'node',
),


 'pattern' => 'node__'
handle base hook

        handle theme hook suggestions


                 pattern




                                        Building registry
'node' => array(
  'render element' => 'elements',
  'template' => 'node',
),


 'pattern' => 'node__'
handle base hook

        handle theme hook suggestions




                                        Building registry
'node__page' => array(
  'template' => 'node--page',
  'path' => 'path/to/mytheme',
  'render element' => 'elements'
  'base hook' => 'node',
),
handle base hook

        handle theme hook suggestions




                                        Building registry
'node__page' => array(
  'template' => 'node--page',
  'path' => 'path/to/mytheme',
  'render element' => 'elements'
  'base hook' => 'node',
),
handle base hook

        handle theme hook suggestions




theme('node__page', $elements);




                                        Using registry
theme(
  array('node__page', 'node'),
  $elements
);
handle base hook

        handle theme hook suggestions




                                        Using registry
theme('node', $elements);
handle base hook

         handle theme hook suggestions




theme('node', $elements);




                                           Using registry
template_preprocess_node

$variables['theme_hook_suggestions'][] =
 'node__' . $node->type;
$variables['theme_hook_suggestions'][] =
 'node__' . $node->nid;
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
execute function or render template file




                                          Using registry
execute function or render template file




                                          Using registry
theme_item_list($variables);
execute function or render template file

find render function

   get extension

preprocess trickery




                                             Using registry
call render function
execute function or render template file

find render function

   get extension

preprocess trickery




                                             Using registry
call render function
execute function or render template file

find render function

   get extension

preprocess trickery




                                                    Using registry
call render function        theme_render_template

        extract variables

       start output buffer

      include template file

        get and return OB
execute function or render template file




                                          Using registry
        return $output;
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
initialize themes

           get theme registry

        get callable theme hook

              include files




                                           Using registry
          handle render array

        get defaults for variables

           handle base hook

execute preprocess and process functions

    handle theme hook suggestions

 execute function or render template file
Sherlock markup & Sammy Semantic
  Andreas Sahle - today at 17.45
?

Theme API

  • 1.
    Theme API Rolfvan de Krol
  • 5.
    Drupal 7.2 -default install bartik views & devel
  • 6.
  • 7.
    $html = theme( 'item_list', array( 'items' => $links, 'title' => t('My links') ) );
  • 8.
    $html = theme( 'item_list', array( 'items' => $links, 'title' => t('My links') ) );
  • 9.
    $html = theme( 'item_list', $links, t(‘My links’) ); $html = theme( 'item_list', array( 'items' => $links, 'title' => t('My links') ) );
  • 10.
    $html = theme( 'item_list', $links, t(‘My links’) ); $html = theme( 'item_list', array( 'items' => $links, 'title' => t('My links') ) );
  • 11.
    ‘theme’ initialization ‘theme registry’ loading finding of callable ‘theme hook’ including of required files handle some ‘render array’ specific stuff merging the defaults into the ‘variables’ getting information from the ‘base hook’ executing ‘preproces’ and ‘process’ functions handling of ‘theme hook suggestions’ executing ‘function’ or rendering ‘template’
  • 12.
    ‘theme’ initialization ‘theme registry’ loading finding of callable ‘theme hook’ including of required files handle some ‘render array’ specific stuff merging the defaults into the ‘variables’ getting information from the ‘base hook’ executing ‘preproces’ and ‘process’ functions handling of ‘theme hook suggestions’ executing ‘function’ or rendering ‘template’
  • 13.
  • 14.
    theme registry theme($hook, $vars)
  • 15.
    hook_theme hook_theme_alter theme registry theme($hook, $vars)
  • 17.
    'item_list' => array( 'variables' => array( 'items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => array(), ), 'type' => 'module', 'theme path' => 'modules/system', 'function' => 'theme_item_list', );
  • 18.
    'page' => array( 'template' => 'page', 'path' => 'themes/bartik/templates', 'type' => 'theme_engine', 'theme path' => 'themes/bartik', 'render element' => 'page', 'preprocess functions' => array( 'template_preprocess', 'template_preprocess_page', 'contextual_preprocess', 'overlay_preprocess_page', 'shortcut_preprocess_page', ), 'process functions' => array( 'template_process', 'template_process_page', 'rdf_process', 'bartik_process_page', ), );
  • 19.
    devel module http://drupal.org/project/devel http://mydrupalinstall.com/devel/theme/registry
  • 20.
    Building registry hook_theme hook_theme_alter
  • 21.
    hook_theme hook_theme_alter Building registry system_theme node_theme phptemplate_theme stark_theme mytheme_theme
  • 22.
    hook_theme hook_theme_alter Building registry system_theme node_theme phptemplate_theme stark_theme mytheme_theme
  • 23.
    theme Building registry base theme(s) modules
  • 24.
  • 25.
  • 26.
  • 27.
    PHPTemplate Building registry Inspects theme
  • 28.
    Inspects theme Building registry Find templates and functions
  • 29.
  • 30.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 31.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 32.
    initialize themes find‘base themes’ register CSS files register JS files Using registry include template.php
  • 33.
    initialize themes find‘base themes’ register CSS files register JS files Using registry include template.php theme engine
  • 34.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 35.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 36.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 37.
    get callable themehook $html = theme( ‘views_view’, array( Using registry ‘view’ => $this->view, ‘options’ => $this->options, ‘rows’ => $rows ) );
  • 38.
    get callable themehook $html = theme( ‘views_view’, array( Using registry ‘view’ => $this->view, ‘options’ => $this->options, ‘rows’ => $rows ) );
  • 39.
    get callable themehook $html = theme( array( ‘views_view__myviewname’, ‘views_view’ ), Using registry array( ‘view’ => $this->view, ‘options’ => $this->options, ‘rows’ => $rows ) );
  • 40.
    get callable themehook $html = theme( array( ns ‘views_view__myviewname’, tio ‘views_view’ es ), gg Using registry su array( ok ‘view’ => $this->view, ho ‘options’ => $this->options, e ‘rows’ => $rows em ) th );
  • 41.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 42.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 43.
    include files ‘status_report’ =>array( 'render element' => 'requirements', 'file' => 'system.admin.inc', 'type' => 'module', Using registry 'theme path' => 'modules/system', 'function' => 'theme_status_report', 'includes' => array( 'modules/system/system.admin.inc', ), ),
  • 44.
    include files ‘status_report’ =>array( 'render element' => 'requirements', 'file' => 'system.admin.inc', 'type' => 'module', Using registry 'theme path' => 'modules/system', 'function' => 'theme_status_report', 'includes' => array( 'modules/system/system.admin.inc', ), ),
  • 45.
    include files ‘status_report’ =>array( 'render element' => 'requirements', 'file' => 'system.admin.inc', 'type' => 'module', 'theme path' => 'modules/system', Building registry 'function' => 'theme_status_report', 'includes' => array( 'modules/system/system.admin.inc', ), ), 'status_report' => array( 'render element' => 'requirements', 'file' => 'system.admin.inc', ),
  • 46.
    include files ‘status_report’ =>array( 'render element' => 'requirements', 'file' => 'system.admin.inc', 'type' => 'module', 'theme path' => 'modules/system', Building registry 'function' => 'theme_status_report', 'includes' => array( 'modules/system/system.admin.inc', ), ), 'status_report' => array( 'render element' => 'requirements', 'file' => 'system.admin.inc', ),
  • 47.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 48.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 49.
    handle render array $elements= array( Using registry '#type' => 'textfield', '#title' => t('My title'), );
  • 50.
    handle render array $elements= array( '#type' => 'textfield', Using registry '#title' => t('My title'), ); $html = drupal_render($elements);
  • 51.
    handle render array $elements= array( '#type' => 'textfield', '#title' => t('My title'), ); $html = drupal_render($elements); Using registry <div class="form-item form-type- textfield"> <label>My title</label> <input type="text" maxlength="128" size="60" class="form-text" /> </div>
  • 52.
    handle render array Using registry hook_element_info
  • 53.
    handle render array hook_element_info array( '#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, Using registry '#process' => array( 'ajax_process_form' ), '#theme' => 'textfield', '#theme_wrappers' => array( 'form_element' ), );
  • 54.
    handle render array $elements= array( '#type' => 'textfield', '#title' => 'Shizzle', '#input' => TRUE, '#size' => 60, '#maxlength' => 128, Using registry '#autocomplete_path' => FALSE, '#process' => array( 'ajax_process_form', ), '#theme' => 'textfield', '#theme_wrappers' => array( 'form_element', ),
  • 55.
    handle render array $elements= array( '#type' => 'textfield', '#title' => 'Shizzle', '#input' => TRUE, '#size' => 60, '#maxlength' => 128, Using registry '#autocomplete_path' => FALSE, '#process' => array( 'ajax_process_form', ), '#theme' => 'textfield', '#theme_wrappers' => array( 'form_element', ),
  • 56.
    handle render array Building registry 'textfield' => array( 'render element' => 'element', ),
  • 57.
    handle render array 'textfield'=> array( 'render element' => 'element', Using registry ), $variables = array( ‘element’ => $elements );
  • 58.
    handle render array Using registry The Scary Render Array Erik Stielstra - today at 15:15
  • 59.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 60.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 61.
    get defaults forvariables $html = theme( 'item_list', array( Using registry 'items' => $links, 'title' => t('My links') ) );
  • 62.
    get defaults forvariables $html = theme( 'item_list', array( Using registry 'items' => $links, 'title' => t('My links') ) );
  • 63.
    get defaults forvariables $html = theme( 'item_list', array( 'items' => $links, 'title' => t('My links') ) Using registry ); 'item_list' => array( 'variables' => array( 'items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => array() ), ),
  • 64.
    get defaults forvariables array( 'items' => $links, Using registry 'title' => t('My links'), 'type' => 'ul', 'attributes' => array() )
  • 65.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 66.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 67.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 68.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 69.
    execute preprocess andprocess functions $variables Using registry preprocess process
  • 70.
    execute preprocess andprocess functions array( 'template' => 'page', 'path' => 'themes/bartik/templates', 'type' => 'theme_engine', 'theme path' => 'themes/bartik', 'render element' => 'page', 'preprocess functions' => array( 'template_preprocess', Using registry 'template_preprocess_page', 'contextual_preprocess', 'overlay_preprocess_page', 'shortcut_preprocess_page', ), 'process functions' => array( 'template_process', 'template_process_page', 'rdf_process', 'bartik_process_page', ), )
  • 71.
    execute preprocess andprocess functions array( 'template' => 'page', 'path' => 'themes/bartik/templates', 'type' => 'theme_engine', 'theme path' => 'themes/bartik', 'render element' => 'page', 'preprocess functions' => array( 'template_preprocess', Using registry 'template_preprocess_page', 'contextual_preprocess', 'overlay_preprocess_page', 'shortcut_preprocess_page', ), 'process functions' => array( 'template_process', 'template_process_page', 'rdf_process', 'bartik_process_page', ), )
  • 72.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 73.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 74.
    handle base hook handle theme hook suggestions views_view_field views_view_field__archive__page__title Using registry node node__page region region__sidebar
  • 75.
    handle base hook handletheme hook suggestions Building registry pattern
  • 76.
    handle base hook handle theme hook suggestions pattern Building registry 'node' => array( 'render element' => 'elements', 'template' => 'node', ),
  • 77.
    handle base hook handle theme hook suggestions pattern Building registry 'node' => array( 'render element' => 'elements', 'template' => 'node', ), 'pattern' => 'node__'
  • 78.
    handle base hook handle theme hook suggestions pattern Building registry 'node' => array( 'render element' => 'elements', 'template' => 'node', ), 'pattern' => 'node__'
  • 79.
    handle base hook handle theme hook suggestions Building registry 'node__page' => array( 'template' => 'node--page', 'path' => 'path/to/mytheme', 'render element' => 'elements' 'base hook' => 'node', ),
  • 80.
    handle base hook handle theme hook suggestions Building registry 'node__page' => array( 'template' => 'node--page', 'path' => 'path/to/mytheme', 'render element' => 'elements' 'base hook' => 'node', ),
  • 81.
    handle base hook handle theme hook suggestions theme('node__page', $elements); Using registry theme( array('node__page', 'node'), $elements );
  • 82.
    handle base hook handle theme hook suggestions Using registry theme('node', $elements);
  • 83.
    handle base hook handle theme hook suggestions theme('node', $elements); Using registry template_preprocess_node $variables['theme_hook_suggestions'][] = 'node__' . $node->type; $variables['theme_hook_suggestions'][] = 'node__' . $node->nid;
  • 84.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 85.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 86.
    execute function orrender template file Using registry
  • 87.
    execute function orrender template file Using registry theme_item_list($variables);
  • 88.
    execute function orrender template file find render function get extension preprocess trickery Using registry call render function
  • 89.
    execute function orrender template file find render function get extension preprocess trickery Using registry call render function
  • 90.
    execute function orrender template file find render function get extension preprocess trickery Using registry call render function theme_render_template extract variables start output buffer include template file get and return OB
  • 91.
    execute function orrender template file Using registry return $output;
  • 92.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 93.
    initialize themes get theme registry get callable theme hook include files Using registry handle render array get defaults for variables handle base hook execute preprocess and process functions handle theme hook suggestions execute function or render template file
  • 94.
    Sherlock markup &Sammy Semantic Andreas Sahle - today at 17.45
  • 95.

Editor's Notes

  • #2 Introduction of me. Mention Hoppinger.\nUsing a monospace font sets the tone. Lots of code.\n\n
  • #3 Images\nAllegory &amp;#x2018;under the hood&amp;#x2019;\n
  • #4 Images\nAllegory &amp;#x2018;under the hood&amp;#x2019;\n
  • #5 Images\nAllegory &amp;#x2018;under the hood&amp;#x2019;\n
  • #6 Images\nAllegory &amp;#x2018;under the hood&amp;#x2019;\n
  • #7 \n
  • #8 \n
  • #9 Usual call to the menu system\n
  • #10 The part we will be talking is mainly the theme function. What does it do? And how?\n
  • #11 Difference between 6 and 7\n
  • #12 The difference in the call lays in the passing of variables.\n
  • #13 What the theme function does. Concepts are highlighted using quotation marks\n
  • #14 The first two items are really to get the theme system running. These are executed only once. \nThe really interesting part is what is done after the theme registry is loaded. This part intensively uses the registry. It actually merely executes what is programmed in the registry.\n
  • #15 Let&amp;#x2019;s first take a look at the theme registry. It is used by the theme function and constructed using hook_theme and hook_theme_alter.\n
  • #16 Let&amp;#x2019;s first take a look at the theme registry. It is used by the theme function and constructed using hook_theme and hook_theme_alter.\n
  • #17 The theme registry is a very big array. You can view it as a big filing cabinet, containing a drawer for every theme hook. \nTake a look at the data for item_list and page. These data are for a basic Drupal 7 install using the normal installation and the devel module enabled. \nFor the item_list variant are a few things worth noting: the system module registers the core theme hooks using it&amp;#x2019;s implementation of hook_theme. And as you can see the function theme_item_list will be called.\nFor the page variant a few other things are interesting. First, a template will be rendered, instead of a function call. Second is that the implementation of this hook came from the bartik theme (see path and theme_path). The type however is theme_engine. The meaning of the &amp;#x2018;render element&amp;#x2019; item will be covered when talking about the render array. process and preprocess functions are available. There is no real difference between process and preprocess functions, but preprocess is executed before process.\n
  • #18 The theme registry is a very big array. You can view it as a big filing cabinet, containing a drawer for every theme hook. \nTake a look at the data for item_list and page. These data are for a basic Drupal 7 install using the normal installation and the devel module enabled. \nFor the item_list variant are a few things worth noting: the system module registers the core theme hooks using it&amp;#x2019;s implementation of hook_theme. And as you can see the function theme_item_list will be called.\nFor the page variant a few other things are interesting. First, a template will be rendered, instead of a function call. Second is that the implementation of this hook came from the bartik theme (see path and theme_path). The type however is theme_engine. The meaning of the &amp;#x2018;render element&amp;#x2019; item will be covered when talking about the render array. process and preprocess functions are available. There is no real difference between process and preprocess functions, but preprocess is executed before process.\n
  • #19 The theme registry is a very big array. You can view it as a big filing cabinet, containing a drawer for every theme hook. \nTake a look at the data for item_list and page. These data are for a basic Drupal 7 install using the normal installation and the devel module enabled. \nFor the item_list variant are a few things worth noting: the system module registers the core theme hooks using it&amp;#x2019;s implementation of hook_theme. And as you can see the function theme_item_list will be called.\nFor the page variant a few other things are interesting. First, a template will be rendered, instead of a function call. Second is that the implementation of this hook came from the bartik theme (see path and theme_path). The type however is theme_engine. The meaning of the &amp;#x2018;render element&amp;#x2019; item will be covered when talking about the render array. process and preprocess functions are available. There is no real difference between process and preprocess functions, but preprocess is executed before process.\n
  • #20 The theme registry is a very big array. You can view it as a big filing cabinet, containing a drawer for every theme hook. \nTake a look at the data for item_list and page. These data are for a basic Drupal 7 install using the normal installation and the devel module enabled. \nFor the item_list variant are a few things worth noting: the system module registers the core theme hooks using it&amp;#x2019;s implementation of hook_theme. And as you can see the function theme_item_list will be called.\nFor the page variant a few other things are interesting. First, a template will be rendered, instead of a function call. Second is that the implementation of this hook came from the bartik theme (see path and theme_path). The type however is theme_engine. The meaning of the &amp;#x2018;render element&amp;#x2019; item will be covered when talking about the render array. process and preprocess functions are available. There is no real difference between process and preprocess functions, but preprocess is executed before process.\n
  • #21 If you want to take a look at the registry itself, which can be very helpful when debugging stuff, you can take a look at the devel module.\n
  • #22 The hooks that build the registry\n
  • #23 Theme alter is rarely used, at least in themes. Modules sometimes use it. They usually put a layer between the original function and and theme() to change some variables, before it enters the normal rendering. This is however in Drupal 7 possible using preprocess function and process functions (will be covered later) because these functions also are available for theme functions.\n
  • #24 Most of the time, themes do not have an implementation of hook_theme. \nThat is the job of the theme engine\n
  • #25 Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
  • #26 Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
  • #27 Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
  • #28 Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
  • #29 Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
  • #30 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #31 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #32 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #33 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #34 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #35 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #36 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #37 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
  • #38 The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\nIt is however possible to create a theme without a theme engine. A theme without an engine must have a mytheme.theme. BUT, then the theme has to implement hook_theme itself!\n
  • #39 Back to what the theme function does. We will look at the building of the registry during the discussion how it is used.\n
  • #40 First it initializes the themes.\n
  • #41 It determines what the current theme is and finds the base theme or base themes. Then it adds the defined css files and js files. (.info).\nAt last it runs the the initialization of the theme. \n
  • #42 \n
  • #43 Get the registry from the cache, or build it.\n
  • #44 To find the callable theme hook, it tries to match the contents of the $hook parameter with the theme registry.\n
  • #45 The hook can be an array, but that is, if you ask me, just a relic from Drupal 6. It is not even used in core. Views still uses it. In Drupal 7 we have theme hook suggestions, which will be covered later.\n
  • #46 The hook can be an array, but that is, if you ask me, just a relic from Drupal 6. It is not even used in core. Views still uses it. In Drupal 7 we have theme hook suggestions, which will be covered later.\n
  • #47 The hook can be an array, but that is, if you ask me, just a relic from Drupal 6. It is not even used in core. Views still uses it. In Drupal 7 we have theme hook suggestions, which will be covered later.\n
  • #48 When the callable theme hook is found, it is going to execute exactly what is setup in that hook.\n
  • #49 The first step is to include the files listed in include files. This is allows preprocess and process functions to be available and allows theme functions to be available.\n
  • #50 \n
  • #51 \n
  • #52 \n
  • #53 \n
  • #54 \n
  • #55 \n
  • #56 \n
  • #57 \n
  • #58 \n
  • #59 \n
  • #60 \n
  • #61 \n
  • #62 \n
  • #63 \n
  • #64 \n
  • #65 \n
  • #66 \n
  • #67 \n
  • #68 \n
  • #69 \n
  • #70 \n
  • #71 \n
  • #72 \n
  • #73 \n
  • #74 \n
  • #75 \n
  • #76 \n
  • #77 \n
  • #78 \n
  • #79 \n
  • #80 \n
  • #81 \n
  • #82 \n
  • #83 \n
  • #84 \n
  • #85 \n
  • #86 \n
  • #87 \n
  • #88 \n
  • #89 \n
  • #90 \n
  • #91 \n
  • #92 \n
  • #93 \n
  • #94 \n
  • #95 \n
  • #96 \n
  • #97 \n
  • #98 \n
  • #99 \n
  • #100 \n
  • #101 \n
  • #102 \n
  • #103 \n
  • #104 \n