2

I have a view page showing fields of an entity. The pages URL set in Views is

entity/%

Now I would like to add some tabs to this views pages that I can't generate with views it self, but have to do it programmatically. Si I tried:

function MY_MOODULE_menu() {
  $items['entity/%eid/edit'] = array(
    'title' => 'Edit',
    'page callback'   => 'MY_MODULE_entity_edit_callback',
    'access callback' => true,
    'page arguments' => array('eid'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 100,
  );  
  return $items;
}

As a menu of the type is MENU_NORMAL_ITEM with the base path entity/% is created by the mentioned view, I thought this should simply work, but it does not: The tab does not show up. (Of course I cleared all caches). Did I got something wrong?

1 Answer 1

2

Path hierarchy is based on string matching; so entity/%eid/edit doesn't come under entity/% (because '%' != '%eid')

There are a couple of other issues, reading between the lines I reckon this is what you're going for:

function MY_MOODULE_menu() {
  $items['entity/%/edit'] = array(
    'title' => 'Edit',
    'page callback'   => 'MY_MODULE_entity_edit_callback',
    'access callback' => true,
    'page arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 100,
  );  
  return $items;
}

function MY_MODULE_entity_edit_callback($eid) {
  // ...
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.