View source
<?php
function variable_example_menu() {
$items['admin/config/system/variable_example'] = array(
'title' => 'Variable example',
'description' => 'Example of auto generated settings form.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'variable_group_form',
'variable_example',
),
'access arguments' => array(
'administer site configuration',
),
);
$items['variable/example'] = array(
'title' => 'Variable example',
'description' => 'List some variables.',
'page callback' => 'variable_example_page_list',
'access arguments' => array(
'administer site configuration',
),
);
$items['variable/realm/%/%'] = array(
'title' => 'Variable example realm',
'description' => 'Example of variable realms.',
'page callback' => 'variable_example_page_realm',
'page arguments' => array(
2,
3,
),
'access arguments' => array(
'administer site configuration',
),
);
return $items;
}
function variable_example_page_list() {
variable_include();
$list = variable_list_group('site_information') + variable_list_group('variable_example');
foreach ($list as $name => $variable) {
$build[$name] = array(
'#type' => 'item',
'#title' => $variable['title'],
'#markup' => variable_format_value($variable),
);
}
return $build;
}
function variable_example_page_realm($realm, $key) {
$variables = variable_store($realm, $key);
$variables += array(
'site_name' => 'Variable example realm',
);
variable_realm_add($realm, $key, $variables);
variable_realm_switch($realm, $key);
return variable_example_page_list();
}