Local Tasks Not Displaying on Dynamic Page in Custom Module
This an interesting problem.
I'm writing a module to modify the Path module so that users can only see/edit aliases for pages that belong to their organic group(s). Currently, when a user goes to Administer > Site building > Path, a page is displayed with a listing of the user's groups. When the user clicks one of the links they are taken to a noncached page that displays the url aliases for the pages associated with that group. The page is not cached because the group id is passed along as an argument.
This is all well and good, but for some reason the tabs that are normally associated with Path ("List" and "Add alias") do not display on the noncached page. They display fine on cached pages; if I code the group id into a cached path (for example, "admin/build/path/group/5", 5 being a group to which the user belongs), the page displays the tabs just fine. My menu structure follows. (Note that I've overriden the default Path tabs in my module. I could have left these out and let Path generate them, but I decided to include them in my menu anyway.)
<?php
function og_path_menu($may_cache){
$items = array();
if ($may_cache){
$items[] = array(
'path' => 'admin/settings/og_path',
'title' => t('OG Path'),
'callback' => 'drupal_get_form',
'callback arguments' => array('og_path_admin_settings'),
'description' => t('Modify Path module for use with Organic Groups'),
'access' => user_access('administer site configuration')
);
$items[] = array(
'path' => 'admin/build/path',
'title' => t('OG Path'),
'description' => t('Overrides the default Path module to provide support for Organic Groups.'),
'callback' => 'og_path_overview',
'access' => user_access('create url aliases'),
'type' => MENU_CALLBACK,
'weight' => 0,
);
$items[] = array(
'path' => 'admin/build/path',
'title' => t('OG Path'),
'access' => user_access('create url aliases'),
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
'path' => 'admin/build/path/list',
'title' => t('List Groups'),
'access' => user_access('create url aliases'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'path' => 'admin/build/path/add',
'title' => t('Add Alias'),
'callback' => 'og_path_edit_alias',
'access' => user_access('create url aliases'),
'type' => MENU_LOCAL_TASK,
);
}
else {
$items[] = array(
'path' => 'admin/build/path/group/' . arg(4),
'title' => t('Group Aliases'),
'callback' => 'og_path_display_aliases',
'access' => TRUE,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'mypath',
'title' => t('My Path'),
'callback' => 'og_path_all',
'access' => user_access('access content'),
'type' => MENU_CALLBACK,
);
}
return $items;
}
?>I'm fairly sure that as far as the menu goes I have coded it correctly, though I could be mistaken. Is there something I might be doing wrong in the menu, or perhaps do I need to code my functions differently? Is this a known issue or is this unique to what I am trying to accomplish?
