0

I have created D7 module called 'mymodule' and enabled it from module list page. But the menu created inside the mymodule_menu() is not being called, instead redirects to 404 page.

Below is the mymodule.info file

name = my custom module
description = My module testing
version = 7.x
package = Custom Modules
core=7.x

Below is the mymodule.module file

<?php
echo 'Module is called';

function mymodule_menu() {

    $items['mydesk'] =  array(
      'title' => 'My Desk' ,
      'page callback' => 'show_mydesk',
      'access arguments' => TRUE,
    );
    return $items;
}

function show_mydesk() {
    echo 'show_mydesk';
}    

Note: the echo 'Module is called' text is printing after enabled the module. Any help to find out where I have missed something.

Thanks Govind

  • Don't use echo, just return the text you want. Are you accessing yoursite.com/mydesk, right? – sanzante Mar 27 '15 at 9:56
2

You need to change access arguments with access callback.

Replace following code:

$items['mydesk'] =  array(
  'title' => 'My Desk' ,
  'page callback' => 'show_mydesk',
  'access arguments' => TRUE,
);

With:

$items['mydesk'] =  array(
  'title' => 'My Desk' ,
  'page callback' => 'show_mydesk',
  'access callback' => TRUE,
);    
| improve this answer | |
  • Yes, It woks when only 'access callback' is present. Thanks dude – Govind Mar 13 '15 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.