You are here

function hook_domainconf in Domain Access 6.2

Same name and namespace in other branches
  1. 5 API.php \hook_domainconf()
  2. 7.2 domain.api.php \hook_domainconf()

Allows modules to add additional form elements for saving as domain-specific settings.

When naming your form arrays, remember that the final key is the name of the variable that you wish to alter. The example below changes the default user picture depending on the active domain.

Preferred use is to wrap your form elements in a named fieldset, for easier viewing.

This hook is implemented by the Domain Conf module.

You may wish to pair this hook with hook_domainbatch() to allow the mass update of your settings.

If you wish to store settings that are not related to another module, you must pass the following parameter:

$form['myform']['#domain_setting'] = TRUE;

Doing so will tell Domain Access that no default settings page exists, and that values must be stored for the primary domain. This feature is useful for creating special data that needs to be associated with a domain record but does not need a separate table.

Using the variable override of hook_domainconf() is an alternative to creating a module and database table for use with hook_domainload().

For site managers who wish to implement this hook in other modules, but cannot wait for patches, you do not need to hack the code. Simply put your functions inside a domain_conf.inc file and place that inside the domain_conf directory. This file should begin with <?php and conform to Drupal coding standards.

Return value

A $form array element as defined by the FormsAPI.

Related topics

2 invocations of hook_domainconf()
domain_conf_api in domain_conf/domain_conf.module
Retrieves elements from hook_domainconf() and formats them as needed.
domain_settings_reset in domain_settings/domain_settings.module
Erase Domain Conf and Batch settings but keep those set by this module.

File

./API.php, line 427
API documentation file.

Code

function hook_domainconf() {
  $form['pictures'] = array(
    '#type' => 'fieldset',
    '#title' => t('User picture'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['pictures']['user_picture_default'] = array(
    '#type' => 'textfield',
    '#title' => t('Default picture'),
    '#default_value' => variable_get('user_picture_default', ''),
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
  );
  return $form;
}