Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:16:44+00:00 2026-06-09T05:16:44+00:00

I want my module to override the path was set by another module Example:

  • 0

I want my module to override the path was set by another module

Example:

Module A has register a path:

$menu['node/%id/test'] = array(
    'title' => 'Test',
    'page callback' => 'test_A',
    'page arguments' => array(1),
    'access callback' => 'test_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
)

Now I create module B and register the same path.

$menu['node/%id/test'] = array(
    'title' => 'Test',
    'page callback' => 'test_B',
    'page arguments' => array(1),
    'access callback' => 'test_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
)

Every request to this path

http://www.mysite.com/node/1/test

will route to module B not A.

What is the best way to override an existing path was set by other module?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:16:46+00:00Added an answer on June 9, 2026 at 5:16 am

    You want to use an alter hook, hook_menu_alter():

    function mymodule_menu_alter(&$items) {
      $items['node/%id/test']['page callback'] = 'test_B';
    }
    

    Since you’re just modifying an existing menu router definition, you only need to declare the part you want to change (e.g., the page callback function name). Note also $items is passed by reference, so you don’t need to return anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to override a method from a module A from another module B
In Kohana 3, how can I override/extend a module class? E.g. I want to
I want to ask something about the new module 'Domain' in node v0.8. var
I would like to use Module functionalTestModule = Modules.override(new ProductionModule()).with(new TestModule()); for test cases
I want to test does my gwt-log module works as expected in my application.
Say you have a page callback from Module #1 using hook_menu(). You want to
I want create module which update list of usb devices automatically (not only mass
I'm writing a module and want to have a unified exception hierarchy for the
I'm writing an Apache module and want to get a string with the Apache
I have created a simple Python module and want to distribute it with pip.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.