hook_domainconf

Versions
domain
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

Code

./API.php, line 424

<?php
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;
}
?>

Buy the Book

Buy your copy of Drupal 7 Module Development today!

It includes my detailed chapter on Node Access in Drupal 7.

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List