Michiel
Michiel

Reputation: 8103

Replace the node-edit menu in Drupal

How can I change (unset or add) a new button in my edit-node menu? In this case, I would like to diable the 'Settings'-menu and add a new menu... I looked in the $form and the $form_state, but no luck there. At least, that's what I think...

enter image description here

EDIT

Module name: publication
Install: publication.install
File: publication.module

function publication_menu_alter(&$items) {
     unset($items['node/%node/edit']);
}

EDIT 2

function publication_menu() {
    $items['node/add/fiche'] = array(
        'title' => 'New linked fiche',
        'type' => MENU_LOCAL_TASK
    );
    return $items;
}

EDIT 3 What I'm trying to do is to allow my users to add some more content to existing content. So they are not allowed to edit the current content, only to add some details. So I thought, I delete the edit-button and replace it with an add-button and the add-button links to a page where he can create more content. That's it :)

Upvotes: 1

Views: 614

Answers (1)

Vlad Stratulat
Vlad Stratulat

Reputation: 1296

You should use hook_menu_alter to unset menu.

function publication_menu_alter(&$items) {
    // print_r($items);
    // Find path you want to unset then unset it.
    // Should be something like:
    unset($items['your/menu/path']);
}

And hook_menu for defining new one. In your case I believe it should be menu type MENU_LOCAL_TASK since you want to add a new tab. Isn't it?

function publication_menu() {
    $items['node/%node/something_else'] = array(
        'title' => 'My title',
        'page callback' => 'mymodule_abc_view',
        'page arguments' => array(1),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK
    );
    return $items;
}

function mymodule_abc_view($nid = NULL) {
    return 'This node ID is '. $nid;
}

Upvotes: 2

Related Questions