1

I have been using Drupal for a few months now at work. I love the developer documentation, but I have to say, I feel like its incomplete -- either that, or I just don't know where to find the other half.

I see documentation for functions and hooks everywhere, but I don't see any documentation for the format of core data structures.

Example one: this page from the official docs has extensive explanation on hook_wysiwyg_editor_settings_alter, but it gives no complete disclosure what the $settings parameter can contain.

Example two: this page from the official docs has great explanation of the concept of "Render Arrays" and the functionality thereof, but has no description of the format of the associative array passed to the render() function, causing me to var_dump($user_page) for hours and come up with monstrosities like: <?php echo $user_page["system_main"]["nodes"][$first_key]["field_objective"]["#object"]->field_targets["und"][0]["safe_value"]; ?> on my custom .tpl.php files.

Is this information in the code itself, or somewhere else?

closed as off-topic by Pierre.Vriens, Shawn Conn, DRUPWAY, Krishna Mohan, kiamlaluno Jan 24 '17 at 10:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Pierre.Vriens, Shawn Conn, DRUPWAY, Krishna Mohan, kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Why echo out values from a render array instead of print render($content['field_name']);? – Kevin Jan 23 '17 at 20:38
  • @Kevin Where does it tell me how to do that in the official docs? – Lincoln Bergeson Jan 23 '17 at 20:40
  • Hooks tend to be documented in MODULE.api.php, often with usage examples. Render arrays can't be documented in the way I think you're looking for as they're loosely formed. Anything with # starting the key is a "property", and provides meta data to whatever function ends up rendering the content, and anything without a # starting the key is itself another render array and rendered recursively – Clive Jan 23 '17 at 20:40
  • For your example: "system_main" is a region, "nodes" is something the page callback for that request has returned as part of a render array, "field_objective" is a field on the node, "#object" is metadata, the object itself which will be used by the rendering function, "field_targets" is a property on that object containing the values. It's quite hard to document that in any meaningful way as it's product of the dynamic system rather than a single predefined process. Once you're comfortable with how render arrays work generically, it'll probably make more sense – Clive Jan 23 '17 at 20:46
  • 1
    drupalcontrib.org is not the official documentation. use api.drupal.org and drupal.org/docs – Eyal Jan 23 '17 at 21:26
1

Render arrays are defined (in Drupal 7) with the hook_element_info hook.

To see what attributes a render element can accept you can check the MODULE_element_info function that defined it.

For example looking at system_element_info we can see that the page render element accepts a #show_messages attribute and that it contains a boolean value.

For more information you can also look for the template_preprocess_ELEMENT function for the element.

template_preprocess_page in our example.

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