18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lastly, the kitten element's #type property is set to link. The #type property<br />

tells drupal_render() how to render that element. When we learn about<br />

hook_element_info(), we'll understand why, but for now drupal_render()<br />

will pass the kitten element to the drupal_pre_render_link() function which<br />

will render the element using l() and return its output.<br />

Chapter 3<br />

Render properties<br />

Render element properties are defined in two places. The first place where properties<br />

are defined is directly inside drupal_render() and its helper functions. The<br />

following is a complete list of properties used by drupal_render():<br />

• #access: A Boolean indicating if the current user has access to view<br />

the element.<br />

• #cache: An array indicating whether the element should optionally<br />

be retrieved from cache or stored in cache after rendering. See<br />

drupal_render() for more information.<br />

• #markup: A string containing markup (such as HTML). If this property is<br />

set, the #type property does not need to be set, as it will automatically be<br />

set to markup.<br />

• #type: A string indicating which element is being rendered. The default<br />

properties for this type of element are extracted from the data specified<br />

with hook_element_info() and merged with the render element.<br />

• #defaults_loaded: A Boolean indicating whether the element type's default<br />

properties have already been loaded. If this is false or not set, the default<br />

properties from element_info() are added before drupal_render() looks<br />

at any other render properties (except for #access and #cache).<br />

• #pre_render: An array of callbacks to apply to the element before theming.<br />

• #theme: A string specifying the theme hook to be used on the element.<br />

• #theme_wrappers: An array of theme hooks to be used on the element after<br />

initial theming and/or after the child elements have been rendered. Theme<br />

functions that are to be used as wrappers need to be specially written to look<br />

for the #children property in the render element passed to it from theme.<br />

• #post_render: An array of callbacks to apply to the element after theming.<br />

• #children: The rendered element and its children. It is normally built up<br />

internally by drupal_render() as it renders the elements, but can also be<br />

set by a #pre_render callback.<br />

• #prefix: A string containing markup to be prepended to the<br />

#children property.<br />

[ 79 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!