Altering the page array

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:08
    You might be asking yourself
  • 0:09
    why would I want to go through all this trouble of defining the content returned by my module
  • 0:13
    as this big structured array with all these crazy pound theme,
  • 0:17
    pound this, pound that, why not just return a string of HTML?
  • 0:20
    The reason for that is we want to delay the rendering of our content to HTML
  • 0:25
    for as long as possible,
  • 0:27
    as this gives other modules and the theme the opportunity to change
  • 0:30
    how these particular items are going to be rendered to HTML.
  • 0:34
    It's a lot easier for PHP to deal with a big associative array,
  • 0:37
    than it is to deal with a string.

Module Development for Drupal 7

Loading ...

Altering the Page Array


This video walks through how to use the new hook_page_alter() in Drupal 7 by transforming an unordered list into an ordered list. Because all of the content, region & blocks are stored within a renderable array before being output to the page, then this new hook allows modules and themes to make changes to page before it is fully rendered.

Log in or sign up to download companion files.
Additional resources: 

Average review

No votes yet