12

I'm trying to add a new link to the Main Menu from inside my module.

Currently, this code:

function custom_food_orders_menu() {
  $items['order_food'] = array(
    'title' => 'Order Food',
    'page callback' => 'page_creator_function',
    'access callback' => TRUE,
        'menu_name=' => 'main-menu',
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

...adds the 'order food' link to the 'Navigation' menu. I tried setting the menu name to main-menu, but that does not seem to work.

Is this a limitation in Drupal? If it is, I'll adjust by creating a link to that page manually.

16

The correct code would be the following one; notice the commented line.

function custom_food_orders_menu() {
  $items['order_food'] = array(
    'title' => 'Order Food',
    'page callback' => 'page_creator_function',
    'access callback' => TRUE,
    'menu_name' => 'main-menu',  // This is the changed line.
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

There aren't properties returned from hook_menu() (and generally from any hook used from Drupal core code) that uses the equal character.

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.