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’
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
40. 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
);
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
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
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 for variables
$html = theme(
'item_list',
array(
Using registry
'items' => $links,
'title' => t('My links')
)
);
62. get defaults for variables
$html = theme(
'item_list',
array(
Using registry
'items' => $links,
'title' => t('My links')
)
);
64. get defaults for variables
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
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
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
87. execute function or render template file
Using registry
theme_item_list($variables);
88. execute function or render template file
find render function
get extension
preprocess trickery
Using registry
call render function
89. execute function or render template file
find render function
get extension
preprocess trickery
Using registry
call render function
90. 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
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
Introduction of me. Mention Hoppinger.\nUsing a monospace font sets the tone. Lots of code.\n\n
Images\nAllegory ‘under the hood’\n
Images\nAllegory ‘under the hood’\n
Images\nAllegory ‘under the hood’\n
Images\nAllegory ‘under the hood’\n
\n
\n
Usual call to the menu system\n
The part we will be talking is mainly the theme function. What does it do? And how?\n
Difference between 6 and 7\n
The difference in the call lays in the passing of variables.\n
What the theme function does. Concepts are highlighted using quotation marks\n
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
Let’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
Let’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
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’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 ‘render element’ 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
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’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 ‘render element’ 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
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’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 ‘render element’ 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
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’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 ‘render element’ 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
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
The hooks that build the registry\n
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
Most of the time, themes do not have an implementation of hook_theme. \nThat is the job of the theme engine\n
Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
Modules form the base, and themes are supposed to override that. Theme overriding is supported by the theme engine.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
The default engine is PHPTemplate. Most engines (also PHPTemplate) inspect the theme and search for theme functions and templates.\n
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
Back to what the theme function does. We will look at the building of the registry during the discussion how it is used.\n
First it initializes the themes.\n
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
\n
Get the registry from the cache, or build it.\n
To find the callable theme hook, it tries to match the contents of the $hook parameter with the theme registry.\n
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
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
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
When the callable theme hook is found, it is going to execute exactly what is setup in that hook.\n
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