Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drupal 7: Render()

weitzman
November 10, 2011

Drupal 7: Render()

An overview of page building and rendering in Drupal 7. See http://2011.badcamp.net/program/sessions/page-render-drill-down-drupal-7

weitzman

November 10, 2011
Tweet

Other Decks in Technology

Transcript

  1. Demonstrations Move node links to a sidebar. Duplicate a block

    into another region. Add banner advert to comment listing. Thursday, November 10, 11
  2. Return render array, not string A single $build[#markup] = ‘foo’

    is lame Don’t call theme() Use #theme=‘table’, not theme(‘table’) Don’t call drupal_render(). Let that happen later. page callback Thursday, November 10, 11
  3. Delivery callback determines output format D7 ships with HTML &

    ajax delivery Future callbacks: Atom, YAML, Docbook Menu item can provide delivery callback hook_page_delivery_callback_alter() - run time changes See WSCCI Initiative for D8 delivery callback Thursday, November 10, 11
  4. Regions Promises made by a theme. I will print this

    to the page. Thursday, November 10, 11
  5. Advantages Maintainability: Customized templates still work. New fields actually output.

    Security: Many folks were printing unsafe data from $node->field_foo Performance: Only theme stuff that gets output Empowerment: Template author has one workplace Backwards Compat: You don’t have to use it! Thursday, November 10, 11
  6. drupal_render() cache Successor of the block cache. Applies to any

    renderable element. Applies when using node access Can use any cache key, expiry, bin. Most uses are site specific. @see forum_block_view() Thursday, November 10, 11
  7. Summary hook_page_alter() enables changing content and positioning dynamically. Safer, more

    maintainable templates Better performance. #cache is tool for better performance for authenticated Thursday, November 10, 11