function disable_breadcrumbs_form_alter in Disable breadcrumbs 7
Same name and namespace in other branches
- 6 disable_breadcrumbs.module \disable_breadcrumbs_form_alter()
Implements hook_form_alter().
File
- ./
disable_breadcrumbs.module, line 187 - Disable breadcrumbs
Code
function disable_breadcrumbs_form_alter(&$form, &$form_state, $form_id) {
$enabled_content_types = variable_get('disable_breadcrumbs_node_types', array());
// Only perform alteration if node edit form, content type is checked in settings, and user has permissions.
if (strpos($form_id, "_node_form") !== FALSE && isset($form['#node']) && in_array($form['#node']->type, $enabled_content_types, TRUE) && (user_access('administer breadcrumbs') || user_access('disable node breadcrumbs'))) {
$form['breadcrumb'] = array(
'#type' => 'fieldset',
'#title' => t("Breadcrumb"),
'#group' => 'additional_settings',
);
$form['breadcrumb']['disable_breadcrumb'] = array(
'#type' => 'checkbox',
'#title' => t("Disable breadcrumb"),
'#return_value' => 1,
'#default_value' => isset($form['#node']->disable_breadcrumb) ? $form['#node']->disable_breadcrumb : '',
'#description' => t("Hide the breadcrumb trail when this node is viewed."),
);
if (!isset($form['#node']->nid)) {
// If it's a new node, add submit handler to node 'save' button submit instead.
$form['actions']['submit']['#submit'][] = 'disable_breadcrumbs_node_form_submit';
}
else {
// Append another submit function to update disabled_node field in node table
$form['#submit'][] = 'disable_breadcrumbs_node_form_submit';
}
}
}