0
votes

I have created a custom module in drupal 7 which shows a navigation menu in admin menu bar , but when I click on it it is not selected . Here is the menu hook

function tableof_content_menu() {
    $items['admin/tableof_content/add'] = array(
    'title' => t('Add TOC'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('tableof_content_admin_add_form'),
    //'access callback' => TRUE,
    'access arguments' => array('administer my module'),
    'type' => MENU_NORMAL_ITEM
  );

   $items['admin/tableof_content/edit/%'] = array(
    'title' => 'Edit TOC',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('tableof_content_admin_add_form',3),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
  ); 

   $items['admin/tableof_content/search/%'] = array(
        'title' => 'Add TOC',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('tableof_content_admin_add_form',3),
        'access callback' => TRUE,
        'type' => MENU_CALLBACK
   );

  return $items;
}

Also I have checked with firebug and in other menu the class "active-trail" is showing which is not appearing in my menu .

Thanks for your help in advance

1
Did you also create a route for admin/tableof_content (the parent of your menu item "add")? - Djouuuuh
I have edited my post @Djouuuuh , please check - Ron
Ok. You created 3 children for the admin/tableof_content "menu". I'm not sure but I think you have to set this route too. Could you have a look at this article: konordo.com/blog/drupal-7-add-custom-link-admin-menu - Djouuuuh
@Djouuuuh thanks for your help but I have tried the trick they provide but after cache clear still it is not working as I am required - Ron
Unfortunately I also found this article (drupal.org/node/942782) that says that custom menu items don't receive "active-trail" class by default... - Djouuuuh

1 Answers

0
votes

Maybe you could do the trick dynamically in each node_view. You get the current node path with $path = menu_get_active_trail() and you set the menu item as active with menu_set_active_item($path). I had to do that once.