function page_title_form_views_ui_config_item_form_alter in Page Title 7.2
Same name and namespace in other branches
- 8.2 page_title.module \page_title_form_views_ui_config_item_form_alter()
- 6.2 page_title.module \page_title_form_views_ui_config_item_form_alter()
Form Alter handler for the views ui config form (used for filters and args)
File
- ./
page_title.module, line 682 - Enhanced control over the page title (in the head tag).
Code
function page_title_form_views_ui_config_item_form_alter(&$form, &$form_state) {
// Don't bother altering non-argument forms
if ($form_state['type'] != 'argument') {
return;
}
$view =& $form_state['view'];
$display_handler =& $view->display_handler;
// Check the display handler is a page - if not, dont bother altering.
if ($display_handler->display->display_plugin != 'page_with_page_title') {
return;
}
// Now check the display has arguments. This ensures we are on an overidden Contextual Filter
if (empty($display_handler->options['arguments'])) {
return;
}
list($display_id, $section, $section_id) = explode('-', $form['#secton']);
$argument_handler =& $form_state['handler'];
// Build a page title options fieldset wrapper
$form['options']['page_title_pattern'] = array(
'#type' => 'fieldset',
'#title' => t('Page Title'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 120,
);
// Add the Page Title field
$form['options']['page_title_pattern']['page_title_pattern'] = array(
'#type' => 'textfield',
'#title' => t('Page Title Pattern'),
'#description' => t('Optionally enter a Page Title Pattern for this argument. This will override the main view Page Title Pattern. You can also use the tokens below.'),
'#default_value' => $argument_handler->options['page_title_pattern'],
'#parents' => array(
'options',
'page_title_pattern',
),
'#element_validate' => array(
'token_element_validate_token_context',
),
'#token_types' => array(),
);
// Add the token help to a collapsed fieldset at the end of the configuration page.
$form['options']['page_title_pattern']['token_help'] = array(
'#type' => 'fieldset',
'#title' => t('Available Tokens List'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['options']['page_title_pattern']['token_help']['content'] = array(
'#theme' => 'token_tree',
'#token_types' => array(),
);
$form['buttons']['submit']['#submit'][] = 'page_title_form_views_ui_config_item_form_alter_submit';
}