1 layout.admin.inc | layout_title_settings_form($form, &$form_state, Layout $layout) |
Form callback; Configure layout title type.
Related topics
File
- core/
modules/ layout/ layout.admin.inc, line 1457 - Admin page callbacks for the Layout module.
Code
function layout_title_settings_form($form, &$form_state, Layout $layout) {
form_load_include($form_state, 'inc', 'layout', 'layout.admin');
$form_state['layout'] = $layout;
$form_state['menu_item'] = NULL;
$form['title_display']['#tree'] = FALSE;
$form['title_display']['title_display'] = array(
'#type' => 'radios',
'#default_value' => $layout->settings['title_display'],
'#options' => array(
LAYOUT_TITLE_DEFAULT => t('Default page title'),
LAYOUT_TITLE_CUSTOM => t('Custom page title'),
LAYOUT_TITLE_BLOCK => t('Copy from block'),
LAYOUT_TITLE_NONE => t('No title'),
),
);
$form['title_display']['title_display'][LAYOUT_TITLE_DEFAULT]['#description'] = t('The page title will pull from a default source. For example: on the user account page, a username may be used.');
$form['title_display']['title_display'][LAYOUT_TITLE_CUSTOM]['#description'] = t('Provide a custom page title for this layout.');
$form['title_display']['title_display'][LAYOUT_TITLE_BLOCK]['#description'] = t('Copy the page title from a block for this layout.');
$form['title_display']['title_display'][LAYOUT_TITLE_NONE]['#description'] = t('Hide the page title for this layout.');
$form['title_display']['title'] = array(
'#type' => 'textfield',
'#default_value' => $layout->settings['title'],
'#title' => t('Custom page title'),
'#description' => t('If left blank, a default title may be used.'),
'#states' => array(
'visible' => array(
':input[name="title_display"]' => array('value' => LAYOUT_TITLE_CUSTOM),
),
),
'#maxlength' => 255,
);
$block_options = array();
foreach ($layout->content as $uuid => $block) {
$title = strip_tags($block->getAdminTitle());
if (!empty($title) && $block->delta !== 'custom_block' && !is_a($block, 'PageComponents')) {
$block_options[$uuid] = $title;
}
}
asort($block_options);
$form['title_display']['title_block'] = array(
'#type' => 'select',
'#default_value' => $layout->settings['title_block'],
'#title' => t('Block to copy'),
'#description' => t('The page title will be taken from this block\'s title.'),
'#states' => array(
'visible' => array(
':input[name="title_display"]' => array('value' => LAYOUT_TITLE_BLOCK),
),
),
'#options' => $block_options,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
'#attributes' => array('class' => array('layout-title-button')),
'#submit' => array(
'layout_title_settings_form_submit',
),
'#save_in_progress' => TRUE,
'#ajax' => array(
'callback' => 'layout_ajax_form_save_title_dialog',
),
);
return $form;
}