0

I know Wordpress theming, but I am a beginner with Drupal theming. Drupal render array totally confuses me.

  1. Do all modules put their content in the $page array?

  2. Is $page only an array that is important for theming purpose? If the answer is no, then what kind of renderable arrays are available in Drupal for advanced theming?

3

There is just a type of render array, and it is the one described in drupal_render(); the form API extends the render array with properties necessary to validate/submit a form element. The purpose of a render array is just to theme elements present in a page; it is not used for other purposes, if not rendering/theming.

The output of a module is always part of a render array, except when a module implements code similar to the following one.

  function mymodule_menu() {
    $items['abc/def'] = array(
      'page callback' => 'mymodule_abc_view',
    );
    return $items;
  }

  function mymodule_abc_view() {
    echo "<html><head><title>Error</title></head><body><span>Error page</span></body></html>";
    drupal_exit();
  }

If you visit http://example.com/abc/def, there isn't any render array involved in rendering the page.

  • sir thanks for your reply and editing. but sir i am still confuse. can you please explain answer in simple word and with theming example. i understand nothing regarding answer to my first quertion(Do all modules put their content in the $page array?) – GiLL Aug 5 '12 at 9:08
  • Do all modules put their content in the $page array? Yes, except in one case. Is $page only an array that is important for theming purpose? The render array is used only for theming, so yes. – kiamlaluno Aug 5 '12 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.