Drupal7 hook_menu for existing node aliases

I am developing my module. For the module I created a special node type and added some nodes with aliases like "events / my1", "events / my2" and "events / my3".

In the module I am using the hook_menu function

$items['events'] = array(
    'title' => t('Events list'),
    'access callback' => TRUE,
    'page callback' => '_events_list',
    'type' => MENU_CALLBACK,
  );
  $items['events/%'] = array(
    'title' => t(''),
    'access callback' => TRUE,
    'page callback' => '_event_detail',
    'page arguments' => array(1),
    'type' => MENU_CALLBACK,
  );

      

On url site.com/events/ opened my page from _events_list () function

At url site.com/events/anyurl/ content is opened from function _event_detail ()

But when I open site.com/events/my1/ then the default view for node opens. Not my code from _event_detail ().

How can I fix this? I want for each url from / events / show code from my function, not the default.

+3


source to share


1 answer


hook_menu

defines new URL paths. For existing url paths use hook_menu_alter

.



0


source







All Articles