phpdrupalcontent-management-systemdrupal-6content-management

Add fields to the Site information section on Drupal 6.12


I've been shifting through the drupal documentation and forums but it's all a little daunting. If anyone has a simple or straight forward method for adding fields to the Site information page in the administration section i'd really appreciate it.

As a background, i'm just trying to add user customizable fields site wide fields/values.


Solution

  • In a custom module, you can use hook_form_alter() to add extra fields to that form. For example:

    function mymodule_form_alter(&$form, $form_state, $form_id) {
      if ($form_id == 'system_site_information_settings') {
        $form['my_module_extra_setting'] = array(
          '#type' => 'checkbox',
          '#title' => t('Use my setting'),
          '#default_value' => variable_get('my_module_extra_setting', TRUE),
        );
      }
    }
    

    Anywhere in your code you need access to the saved setting itself, you can use the same call that's used to populate that form element's default value: variable_get('my_module_extra_setting', TRUE)