AllisonC
AllisonC

Reputation: 3099

Why am I getting a page not found error after creating a new menu item?

In my module file I created a new menu item

function xmlproject_menu() 
{
  $items = array();

  //more items here

  $items['system/xml/cfa/initialize/%/%/%/%/%'] = array(
    'page callback' => 'xmlproject_initialize_cf',
    'page arguments' => array(4, 5, 6, 7, 8,),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function xmlproject_initialize_cf($session_id, $cart_id, $pid, $rid, $partner_id)
{
  //some code here
}

I have tried going to admin/build/modules, devel/menu/reset, and admin/settings/performance to clear the cache. I can see the menu item in the database (menu_router). enter image description here

When I go to http://example.com/system/xml/cfa/initialize/1/2/3/4/5 I am getting "Page not found".

Upvotes: 4

Views: 148

Answers (3)

Shirin Abdolahi
Shirin Abdolahi

Reputation: 1067

As you see in your database number_part column that contains Number of parts in router path,sets to 7(maximum available part),but your parts of menu callback is 9.Which is more than MENU_MAX_PARTS available in drupal 6. this is why you're getting Page not found Just reduce your menu item size and you are good to go.for example:

$items['initialize/%/%/%/%/%'] = array(
    'page callback' => 'xmlproject_initialize_cf',
    'page arguments' => array(4, 5, 6, 7, 8),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
 );

Upvotes: 1

Gyanendra Dwivedi
Gyanendra Dwivedi

Reputation: 5538

Does not seems anything wrong with your code. Just curious, why you have kept the last element of array as 'empty' (a comma after number 8)

'page arguments' => array(4, 5, 6, 7, 8,),

Also, there is additional empty item in the array (extra comma after MENU_CALLBACK)

'type' => MENU_CALLBACK,

Upvotes: 1

user3868349
user3868349

Reputation:

You code seems all dandy, but I suppose your page callback "xmlproject_initialize_cf" should actually return something.

Try this:

function xmlproject_initialize_cf($session_id, $cart_id, $pid, $rid, $partner_id)
{
  // Your Code
  return 'Hello world!';
}

Is the modules name "xmlproject"?

Upvotes: 1

Related Questions