1

I made a module for displaying nodes(links) from database. And I have simple question, why are the links displayed in the navigation menu? I want to be displayed in a separate menu (like navigation menu with my custom title etc etc...), but whatever I do they show up in the navigation menu.

enter image description here

function test_menu(){

$items = array(); 

  $items['test1'] = array(
    'title callback'   => 'test_callback1',
    'page callback'    => 'test_output1',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,
  );

      $items['test2'] = array(
    'title callback'   => 'test_callback2',
    'page callback'    => 'test_output2',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,

  );
       ..... etc etc
      return $items;
}

This is page-test.tpl.php

<?php
 print $content;
 ?>
1

It's because you're using the MENU_NORMAL_ITEM type, which will add the item to a menu, and haven't set a menu_name. From the docs:

"menu_name": Optional. Set this to a custom menu if you don't want your item to be placed in Navigation.

If you want to add the link to a different menu try something like this:

$items['test1'] = array(
  'title callback'   => 'test_callback1',
  'page callback'    => 'test_output1',
  'access arguments' => array('access content'),
  'type' => MENU_NORMAL_ITEM,
  'menu_name' => 'main-menu'
);

If you don't want the link to be added to a menu automatically at all, change MENU_NORMAL_ITEM to MENU_CALLBACK.

Remember to clear the caches when you make any change to hook_menu(), otherwise the changes won't be picked up.

  • I understand, main-menu works, change links destination, and now I need to create custom menu with hook_install or so? Tnx for reply. – Prafix Nov 7 '12 at 13:40
  • Yes you can create a menu in hook_install (or maybe hook_enable if that suits better), or you can just create it through the UI as normal – Clive Nov 7 '12 at 13:50

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.