demo.module
function demo_menu(){
$items['admin/config/demo'] = array(
'title' => 'Node demo',
'description' => 'Adjust node demo options',
'position' => 'right',
'weight'=> -5,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/demo/settings'] = array(
'title' => 'demo Settings',
'description' => 'Change how demo behave',
'page callback' => 'drupal_get_form',
'page arguments' => array('demo_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'demo_posts.inc'
);
return $items;
}
demo_posts.inc
function demo_admin_settings($form, &$form_state){
$types = node_type_get_types();
foreach($types as $node_type) {
$options[$node_type->type] = $node_type->name;
}
$form['demo_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may demo these content types'),
'#options' => $options,
'#default_value' => variable_get('demo_node_types', array('page')),
'#description' => t('A text field will be available on these content types
to make user-specific notes.'),
);
$form['#submit'][] = 'demo_admin_settings_submit';
return system_settings_form($form);
}
Output:
function demo_menu(){
$items['admin/config/demo'] = array(
'title' => 'Node demo',
'description' => 'Adjust node demo options',
'position' => 'right',
'weight'=> -5,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/demo/settings'] = array(
'title' => 'demo Settings',
'description' => 'Change how demo behave',
'page callback' => 'drupal_get_form',
'page arguments' => array('demo_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'demo_posts.inc'
);
return $items;
}
demo_posts.inc
function demo_admin_settings($form, &$form_state){
$types = node_type_get_types();
foreach($types as $node_type) {
$options[$node_type->type] = $node_type->name;
}
$form['demo_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may demo these content types'),
'#options' => $options,
'#default_value' => variable_get('demo_node_types', array('page')),
'#description' => t('A text field will be available on these content types
to make user-specific notes.'),
);
$form['#submit'][] = 'demo_admin_settings_submit';
return system_settings_form($form);
}
Output: