Solved

Create a Drupal 6 Action to Delete a Nodes menu link

Posted on 2009-04-07
1
555 Views
Last Modified: 2013-11-10
Hi Experts,

I'm proficient in PHP but novice in Drupal. I have Actions, Triggers and Workflow setup. From what I've read I need to create a function to implement hook_action_info() and a callback function which calls menu_link_delete. Does anybody know what I'm talking about and can anybody tell me how to do this?

To be precise when a Workflow transition is triggered on a particular Node (called Exhibition) I want an Action that removes any reference to the Node from the Primary Navigation menu.

Thanks!
mstrelan
0
Comment
Question by:mstrelan
1 Comment
 
LVL 10

Accepted Solution

by:
mstrelan earned 0 total points
ID: 24104118
Well no one replied but I found the solution myself. 1. Make a module 2. Create an action. See below
; File menu_unlink.info

name = "Menu Unlink"

description = "Provides menu unlinking actions for nodes"

core = 6.x
 

' File menu_unlink.module

<?php

function menu_unlink_action_info() {

  return array(

    'menu_unlink_remove_from_menu_action' => array(

      'type' => 'node',

      'description' => t('Remove from menu'),

      'configurable' => FALSE,

      'behavior' => array('changes_node_property'),

      'hooks' => array(

        'nodeapi' => array('presave'),

      ),

    ),

  );

}
 

function menu_unlink_remove_from_menu_action(&$node, $context = array()) {

  menu_link_delete(NULL, 'node/' . $node->nid);

}

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP string issue 5 18
Filter wordpress query 3 13
PHP json decode 9 26
LOAD DATA LOCAL INFILE problem 11 21
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now