Community & Support

Edit node menu settings part - disable item?

When I edit a node I have the option to add a menu item to the node (for example to a story or page). What I require is the option to immediately disable that menu item.

Can anyone tell me how to enable such a option so that I don't have to go to the menu admin after creating the node including the menuitem.

If this is not possible with standard functionality, can anyone tell me then where I can find the code which is used to create the menu settings in the "Add Story" page. I think it can be possible to create somekind of module to add a standard disable option?

Comments

=-=

not a standard setting. menu code is located in the menu.module. I'd suggest a custom module rather than hacking any core code.

Maybe this is not the better

Maybe this is not the better way to do it, but it works for me:

Adding this code in menu.module at function menu_form_alter():

<?php
$form
['menu']['hidden'] = array(
     
'#type' => 'checkbox',
     
'#title' => t('Hidden'),
     
'#default_value' => $item['hidden'],
     
'#description' => t('Menu items that are hidden will not be listed in any menu.'),
    );
?>

I am posting a patch here: http://www.bakersys.com/drupal-6-hidden-menu-item-node-edit-page

Hi,Isn't making a custom

Hi,

Isn't making a custom form_alter not a better thing to do: http://blog.rapiddg.com/2011/01/adding-hidden-checkbox-to-node-menu-edit...

There is an error in that code, the correct code is:

<?php
/**
* Implementation of hook_form_alter
*/
function custom_menu_form_alter(&$form, $form_state, $form_id) {
if (isset($form['#node']) && $form['#node->type'] .'_node_form' == $form_id) {

$item = $form['#node']->menu;
$form['menu']['hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hidden'),
'#default_value' => $item['hidden'],
'#description' => t('Menu items that are hidden will not be listed in any menu.'),
);

}

greetings,
Martijn

Change this line from if

Change this line from
if (isset($form['#node']) && $form['#node->type'] .'_node_form' == $form_id) {
into
if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
to make it work.

Developing a module for D7

I have a project started that creates this sort of functionality for D7 that is awaiting approval to become a Drupal module. If anyone is interested in this functionality for D7, you can visit my project page at:
http://drupal.org/sandbox/blischalk/1086674