Andrew’s posterous

 
« Back to blog

notes from moshe's talk on drupal 7 theming at #drupalcon

overview
significant changes to themeing/rendering subsystem
easier to change content and positioning dynamically
hook_page_alter == single, powerful hook for site builders

$page
$page array = structure, unthemed representation of page content
enables modification of elements using hook_page_alter, then passed to drupal_render
renderable elements prefixed with #
sidebar_first == old left. semantically correct
new addition to devel module that will display page array
ideal for custom site modules, rather than contribs
duplicating a block simple as copying an array element eg $page['myregion']['myblock'] = $page['oldregion']['oldblock'] - sim to eg moving part of a node (eg links) to another region (eg sidebar)
blurs the line between devs and themers. imo increases significace of The Themer.

new cache
any renderable element is cacheable
arbitrary cache keys (eg OG id, role etc)
arbitrary cache expiry time (eg force element cache reload each hour irrespective of anything else)
pre_renderer function name is assigned in #pre_render, called when cached version is not present

renderer
add css js to render elements #attached_js, #attached_css. Do not use drupal_add_js/css - required for good cacheing

theming
jqueryui included
granular themeing. takes a while to appreciate :)
    hide($content['comments']);
    print render($content);
    print "some stuff";
    print render($content['comments']);
hide function - modifies renderable array so they (and presumably children?) not printed by render
render function - renders individual elements (and presumably children?)

tips for developers
menu callbacks should return array, not strings
use hook_page_alter early as possible -> means that altered stuff is available down the line to other modules as early as possible
do not use drupal_render, drupal_add_css, drupal_add_js


Loading mentions Retweet

Comments (0)

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     Connect     twitter