hook_menu in drupal 7 when i pass url. It shows Page Not Found

674 Views Asked by At

here is my code

function custom_menu() {
  $items['award/offer'] = array(
    'page callback' => 'award_offer_email',
    'page arguments' => array(1,3),
    'type' => MENU_CALLBACK,
  );
}

Here I have passed the url like http://dev.webroot.com/award/offer but I am getting

The requested page "/award/offer" could not be found.

Any ideas?

3

There are 3 best solutions below

0
On
function custom_menu() {
   $items['award/offer'] = array(
    'page callback' => 'award_offer_email',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );

  return $items;
}

Clear cache menu (if you are using drush : drush cc menu) and refresh your page

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7.x

3
On

Did you clear cache after updating hook_menu()?

0
On

first you need to return your menu items. Other than that you also need to give access to your arguments.

Rewriting Your Example:

function custom_menu() {
   $items['award/offer'] = array(
    'page callback' => 'award_offer_email',
    'page arguments' => array(1,3),
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );

  return $items;
}

Now clear your cache and check it!