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.

Chapter 5<br />

This is used in a variety of display contexts—as your page's heading, in the HTML<br />

tag and as a subheading in the administration interface in combination<br />

with the description (if you are defining an administrative menu item).<br />

'description' => 'Configuration for the User Warn module.',<br />

The description is just that—a longer text description of the page that this menu<br />

item defines. This should provide the user with more detailed information about the<br />

actions they can take on this page. This description is also used as the title tag when<br />

you hover over a link.<br />

Menu item titles and descriptions are passed through t() internally<br />

by <strong>Drupal</strong>, so this is one case where we don't need to worry about<br />

doing that ourselves.<br />

For an administration page, these two items define how your page is listed in<br />

<strong>Drupal</strong>'s admin area as shown in the following:<br />

The next two items define what will happen when your page is requested:<br />

'page callback' => 'drupal_get_form',<br />

'page arguments' => array('user_warn_form'),<br />

'page callback' defines the function that will get called (without the parentheses)<br />

and 'page arguments' contains an array of arguments that get passed to<br />

this function.<br />

Often you will create a custom function that processes, formats, and returns<br />

specific data. However, in our case we are calling the internal <strong>Drupal</strong> function<br />

drupal_get_form() that returns an array as defined by <strong>Drupal</strong>'s Form API. As an<br />

argument we are passing the form ID of the form we want to display. We will dive<br />

into drupal_get_form() and the Form API in more detail later in the chapter.<br />

The fifth item controls who can access your page.<br />

'access arguments' => array('administer users'),<br />

[ 123 ]

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

Saved successfully!

Ooh no, something went wrong!