This hook enables modules to register paths in order to define how URL requests are handled.

learn more… | top users | synonyms

1
vote
3answers
34 views

Render alternative content if user is logged in instead of redirecting to user/uid

I have a menu router with type MENU_CALLBACK and it's 'page callback' property points to a function that implements render API, as follow: /** Implements hook_menu **/ function custom_render_menu() ...
0
votes
0answers
22 views

How to use URL arguments despite using pag argument in hook_menu? [closed]

I am beginning to learn Module dev and i am stuck with a doubt in page argument I was going thru Apress pro Drupal development and i understood from the example that the page argument if used ...
0
votes
1answer
34 views

Entityform - “The form has become outdated.” error

I have an entityform that appears on a page, for some reason the form will not submit ... // implement hook_menu function foiagen_menu() { $items['node/%node/foiagen'] = array( 'title' => ...
0
votes
1answer
18 views

Access denied: 'view published content' permission

When I look into admin/people/permissions: 'View published content' is checked for anonymous users. Yet the following code: function test_menu() { $items['test'] = array( 'title' => 'Test', ...
0
votes
0answers
11 views

Add a link in a menu

I want to create a menu of existing page via hook. I have a module that is called dw_blocks, which contains a hook_menu () In this function, I create a new 'step' menu that works. And now, I will ...
0
votes
2answers
40 views

How do I add HTML to my module's custom admin page?

I have set up a new page in my admin for my module like so: /** * Implements hook_menu(). */ function scraper_menu() { $items = array(); $items['admin/scraper'] = array( 'title' ...
0
votes
1answer
36 views

How to create main links like home ,services programatically? [closed]

I am creating a new website in Drupal 7,but from my past efforts I tried adding main menu links(home,services,clients,blog etc)but all in vain!! Can anyone tell me how to create main menu links ...
0
votes
1answer
16 views

Translate menu with wildcard

I am creating a menu item using hook_menu() and what I want is to translate it when I am using a wildcard, because I have a multilingual site. There is a solution, using t()[, but it's not the best ...
0
votes
2answers
29 views

hook_menu implementation producing error page

I am trying to create a new module implementing hook_menu, to render a page on my company's web site, which I have taken over from the external firm who designed it. There are other modules that use ...
1
vote
2answers
32 views

Hook_menu() and its page callback: how to redirect users on a condition?

I'm trying to redirect users from an existing path in Drupal 7 to another existing path. I want to implement the following rule: comment/reply/123 should redirect to node/123#comment-form But ...
1
vote
1answer
13 views

Add items to router but not links

According to the last paragraph: https://api.drupal.org/api/drupal/includes%21menu.inc/group/menu/7 Everything described so far is stored in the menu_router table. The menu_links table holds ...
0
votes
0answers
32 views

Need advice on how to go about creating a very specific custom menu

I have the need to create a custom menu that is giving me quite the challenge. I have a site that focuses around properties as the main content type. Several other content types have references to the ...
0
votes
1answer
28 views

Override user/%user page callback for a role

I have done this by altering the 'page callback' for the path and then checking for the user role in the callback function. I am not sure if this is the best way to go about it. function ...
0
votes
1answer
41 views

Menu tab with count

I am trying to add a menu tab on the user profile page with the # of blog posts someone has made. Ex: Blogs (3) /** * Implementation of hook_menu */ function menutab_followers_menu() { $view = ...
0
votes
0answers
16 views

hook_menu for organic groups

I have some menus for my organic groups generated by views. But I want to replace them in my custom module and use hook_menu to register the menu for real. But I cant get it to work. All paths used ...
0
votes
1answer
31 views

Custom status message on a Views page

I have different urls : domain.com/blog : a list of articles made with Views module domain.com/blog/article-title : article alias domain.com/newsletter/confirm/add/xyz/ok : confirmation link sent to ...
0
votes
0answers
26 views

Render node with tabs in Drupal 7

If I set up a menu callback with this function: function mymodule_menu_callback($nid) { $node = node_load($nid); return drupal_render(node_view($node)); } Then when the node is rendered it ...
1
vote
0answers
16 views

How do I give access provided user has at least one type of access granted?

I use Drupal 7. My module implements two types of access permissions, named: access MYMODULE foo access MYMODULE bar I want to grant a user access to a particular path (node/%node/MYMODULE) ...
0
votes
1answer
35 views

How to put a link / menu at the top of the edit-user profile page? [closed]

How can I put a link / menu in the edit-user-profile page, in the upper right corner? This link will open a new page with a form created. I've been watching a few examples but I could not ...
0
votes
2answers
63 views

Customising user profile tabs

I've customised the user profile tabs to look like a dashboard by using the generated classes and styling them using just CSS. Just to be clear, I haven't used any hooks or preprocesses to render the ...
0
votes
1answer
29 views

Printing Region With Content in Custom HTML

I am creating a custom first page that is blank and built up from scratch. However I want to print certain regions (e.g. the footer) on this page. How can I grab the region information/content and ...
0
votes
0answers
20 views

Why can we not name our wildcards in HOOK_menu()? [duplicate]

Pretty generic question but in D7 when creating a new menu item with a wildcard, why can I not name my wildcards something generic so that the code is easier to understand? E.g. This doesn't work: ...
2
votes
1answer
82 views

Can local actions have multiple parents?

I have a module that I am working on that defines some local tasks and local actions for node pages, eg $items['node/%node/foo'] = array( 'title' => 'Foo', 'page callback' => 'foo', ...
0
votes
0answers
11 views

How to print a link to the ajax-deliverable path created using hook_menu?

I have created a ajax-deliverable path using hook_menu(). Here is the code: function custom_module_menu() { $items = array(); $items['get_mempages'] = array( 'page callback' => ...
0
votes
0answers
30 views

Unable to add tab to Contact form

I am trying to add a tab to the administration page for the contact form. The page appears if I enter the path, but it does not appear as a tab on admin/structure/contact. I can't see what I am doing ...
0
votes
0answers
40 views

how to extend a custom module

I am writing 2 modules, one dependent on the other and both extend the user profile page. The first one is order_history and the other one order_details. The concept is order_history pulls out a list ...
7
votes
4answers
337 views

Should I use t() in a hook_menu's description?

I have always used t() for hook_menus title and description like this: $items['some-path'] = array( 'title' => t('My Page Title'), 'description' => t('This is a description about what ...
3
votes
2answers
94 views

Would redirecting users in hook_menu's access callback have any undesirable effects?

This answer led to a discussion about the best way to redirect a user to a specific page if they shouldn't have access to the page they are trying to access. One option is to set the access callback ...
0
votes
1answer
44 views

Why page call back is not needed in Ajax jQuery Drupal 6?

function example_menu() { $items['example-menu'] = array( 'page callback' => 'get-result', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ...
1
vote
1answer
187 views

How add tab menu item with external link to article node content

I want to add an extra tab menu item to article node type. I mean a new menu item beside view, edit and other tabs only in article node. but this tab menu item has external link to another site and ...
1
vote
2answers
55 views

Add .active class when certain view is executed using hook_menu

I have a view that is not related with a menu but I need to add .active class to an element of this menu when the view is shown. How can I alter the element adding a class active?
0
votes
2answers
36 views

hook_menu not producing expected tab structure, problem?

I'm trying to create a tabbed menu system with hook_menu() following the hook documentation and Clive's answer. I am using the following code. /** * Implements hook_menu(). */ function ...
0
votes
1answer
23 views

Hook path in main menu not hold active trail

In custom module names supply_area I've created custom path. function supply_area_menu() { $items['supply-area'] = array( 'title' => 'Supply area', 'page callback' => ...
0
votes
1answer
39 views

Remove disabled menu links from menu settings

I have a multilingual site, and when adding content theres an option to add a menu link. Both languages show up in the drop down selection, my goal is to hide/remove the links that are "disabled" (NOT ...
1
vote
2answers
52 views

It is possible to set up a menu item with hook_menu that points to an existing path?

The accepted answer here by marcvangend explains how to it with hook_menu_alter. His method works, even if you skip step one (the block View). But just out of interest: Can you do this by means of ...
0
votes
2answers
34 views

Show a menu item as expanded if on a certain node type

I have a News menu item, which then has children. I need it to be expanded if it is on a news article page, but not expanded on other certain pages. I'm not sure which hook to use. i've played around ...
0
votes
0answers
17 views

Custom Main Menu Text [on hold]

I want to generate custom text for one of the buttons on my pages main menu. Basically, if a user is logged in and has a first name defined in their profile it should read "Fist Name" otherwise it ...
0
votes
0answers
52 views

I'm getting 'page not found' when trying to access my custom module

I am working from a pre-existing Drupal 7 install. I downloaded the source files and downloaded a dump of the DB. When I first installed Drupal worked fine. I built a custom module, it was working ...
1
vote
1answer
67 views

Why is menu item for custom module not showing?

I'm new to Drupal and about to write my first custom module ("configurator") with help of the drupal documentation. I've implemented the menu hook: function configurator_menu() { $items = ...
0
votes
0answers
30 views

Make hook_menu() argument as global variable

here's the code from my module: function vasya_init() { // ajax framework drupal_add_library('system', 'drupal.ajax'); drupal_add_library('system', 'jquery.form'); } function vasya_menu() { ...
1
vote
1answer
33 views

Getting hook_menu() to respond to a URN

I have a site that can respond to URNs. For example, I need to be able to serve up a response to http://example.com/urn:myscheme:foo:bar:12345 So, I need a router item that can match against the ...
0
votes
0answers
17 views

Drupal Views Dynamic Pages And Aliases

I have a custom module that reads data from an external database. How can I make a separate page for each item with the alias '/pages/ItemTitle' and content 'ItemContent'? The following is in my ...
1
vote
0answers
74 views

Use ajax class doesn't work correctly

I have a custom module that should makes link open with ajax . the module works correctly in hook_menu , but i want to open some nodes from main menu with ajax by adding use-ajax class . here is my ...
0
votes
1answer
22 views

Manage main menu in module

I have a series of sites that use the same theme. What I'm looking to achieve is to manage the main menu (or a standard menu) via a module instead. Reasoning: Most of these sites will have the menu ...
1
vote
1answer
38 views

Custom Top Admin Menu: Intergrating Permissions

Looking into build a top bar to be used for clients for quick access to edit/add pages. Big question I have is, how do you hook this into the Permissions module in core? Say if I want to allow another ...
0
votes
0answers
88 views

Open nodes from menu in ajax mode

I have a custom module that shows node in ajax mode with hook_menu() . how can i show nodes from menu in ajax mode . here is my code : <?php /** * Implements hook_menu(). */ function ...
1
vote
2answers
38 views

I can't get my module to show up in the Navigation

I'm trying to create a custom module that has a block with a form in it. I'm able to install my module, and even add the block to the content area of the site, showing my form on every page of the ...
0
votes
1answer
55 views

Making menu wrapped in nav tag

I've got problem with making main-menu wrapped in element. I've tried: Using hooks in template.php like: function koko_menu_link_main_menu($variables) { /* For block override */ $output = ...
0
votes
1answer
50 views

I can't get hook_menu() to work

Hi I am running the code on p247 of "Pro Drupal 7 Development", which includes the code below and then defines a form. I have enabled the module and cleared the cache but this isn't showing up in my ...
0
votes
0answers
45 views

Programmatically nest a menu / define a parent relationship in hook_menu?

I have a custom module that created a menu via code, UI and features. It looks something like this: I am writing a new custom module, and with code, I want to add a menu item that's nested / is ...