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.

Next, let's create a form to enter in default contact information for the site-wide<br />

contact form. In this case we expand the store_install_tasks() function to<br />

add a task for the form.<br />

/**<br />

* Implements hook_install_tasks().<br />

*/<br />

function store_install_tasks() {<br />

$tasks = array();<br />

$tasks['store_create_content_types'] = array(<br />

'type' => 'normal',<br />

);<br />

$tasks['store_configure_contact_form'] = array(<br />

'display_name' => t('Default site contact information'),<br />

'type' => 'form',<br />

);<br />

return $tasks;<br />

}<br />

Chapter 12<br />

In this chapter you will notice the use of the t() and st()<br />

functions for translations. The t() function is the standard<br />

function to use for translatable text. The st() function should be<br />

used when some of the systems are not available. For example, in<br />

the tasks of the installer before the modules are installed. If there<br />

are functions that need to be called in both places and you need<br />

to discover which function to use, get_t() returns the name of<br />

the appropriate translation function to use.<br />

After the task store_create_content_types, the task store_configure_contact_<br />

form is added. We provide this task with a display_name so it will show up as a<br />

step in the installer. The type is set to a form. Just like any other <strong>Drupal</strong> form, it will<br />

have access to FORM_ID_validate and FORM_ID_submit callbacks.<br />

Once a profile has been selected in the first step of the installer, any additional task<br />

will be displayed using their display_name in the installer steps.<br />

[ 351 ]

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

Saved successfully!

Ooh no, something went wrong!