18.10.2016 Views

Drupal 7 Module Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Drupal</strong> Permissions and Security<br />

To finish this example, let's add our theme function to produce the proper output.<br />

if (!empty($list)) {<br />

// Prepare the information for theming.<br />

$variables = array(<br />

'items' => $list,<br />

);<br />

$content = theme('item_list', $variables);<br />

// Attach the content to the user page according to the API.<br />

if (!isset($account->content['example'])) {<br />

$account->content['example'] = array();<br />

}<br />

$account->content['example'] += array(<br />

'#type' => 'user_profile_category',<br />

'#attributes' => array('class' => array('user-member')),<br />

'#weight' => 5,<br />

'#title' => t('Content'),<br />

);<br />

$account->content['example']['output'] = array(<br />

'#type' => 'user_profile_item',<br />

'#title' => t('Content creation permissions'),<br />

'#markup' => $content,<br />

'#attributes' => array('class' => array('content-creation')),<br />

);<br />

}<br />

}<br />

With this theme function in place, we can display the following output:<br />

[ 216 ]

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

Saved successfully!

Ooh no, something went wrong!