I've been fighting with this for a couple weeks now with no
resolution, so I'm hoping someone can shed some light on this for
me. I tried using the menu tabs capability in Views with no luck,
so I'm trying to accomplish the same thing in a module, still with
no luck, and I don't have much hair left to pull out...
What I want to do is create a page with three tabbed menu items.
The text will be from a Page node, and the three tabs will be
views. There are three roles - regular, associate, and affiliate -
that need to have access. Regular and Associate can see all items,
and Affiliate role can only see what has been flagged as being
visible to the Affiliate role. There are three categories - Basic
Information, Best Practices, and Technology. I've created six views
accordingly. What I'm trying to do is create two menu items: one
for Regular/Associate, and one for Affiliate, with the same intro
text. Each will have three tabs, but the views will be different
Here is my hook_menu:
function mymodule_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'resource-center/reg-assoc',
'title' => t('Resource Center - Regular'),
'description' => t('Resource center for regular and associate
members'),
'callback' => 'resource_center_base_page',
'access' => user_access('regular'),
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
'path' => 'resource-center/reg-assoc/basic',
'title' => t('Basic Information'),
'description' => t('Basic Information'),
'callback' => 'resource_center_basic',
'callback argument' => 'resources_reg_assoc_basic',
'access' => user_access('regular'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array(
'path' => 'resource-center/reg-assoc/best-practices',
'title' => t('Best Practices'),
'description' => t('Best Practices'),
'callback' => 'resource_center_best',
'callback argument' => 'resources_reg_assoc_best',
'access' => user_access('regular'),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'resource-center/reg-assoc/technology',
'title' => t('Technology'),
'description' => t('Technology'),
'callback' => 'resource_center_technology',
'callback argument' => 'resources_reg_assoc_technology',
'access' => user_access('regular'),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'resource-center/affiliate',
'title' => t('Resource Center - Affiliate'),
'description' => t('Resource center for affiliate members'),
'callback' => 'resource_center_base_page',
'access' => user_access('affiliate'),
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
'path' => 'resource-center/affiliate/basic',
'title' => t('Basic Information'),
'description' => t('Basic Information'),
'callback' => 'resource_center_basic',
'callback argument' => 'resources_affiliate_basic',
'access' => user_access('affiliate'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items[] = array(
'path' => 'resource-center/affiliate/best-practices',
'title' => t('Best Practices'),
'description' => t('Best Practices'),
'callback' => 'resource_center_best_practices',
'callback argument' => 'resources_affiliate_best',
'access' => user_access('affiliate'),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'path' => 'resource-center/affiliate/technology',
'title' => t('Technology'),
'description' => t('Technology'),
'callback' => 'resource_center_technology',
'callback argument' => 'resources_affiliate_technology',
'access' => user_access('affiliate'),
'type' => MENU_LOCAL_TASK,
);
}
return $items;
}
The URLs for the views match the paths for the MENU_LOCAL_TASK items.
Here is the function to call the page (as referred to in the menu
callback:
function resource_center_base_page() {
$output = '';
$base_node = node_load(84);
$display = node_view($base_node);
$output = $display;
return $output;
}
and then the functions to call the views:
function resource_center_basic($view_name) {
$view = views_get_view($view_name);
print views_build_view('embed', $view, array(), false, false);
}
function resource_center_best_practices($view_name) {
$view = views_get_view($view_name);
print views_build_view('embed', $view, array(), false, false);
}
function resource_center_technology($view_name) {
$view = views_get_view($view_name);
print views_build_view('embed', $view, array(), false, false);
}
After all that, what's happening is that the menu items are only
available to my admin user (the first one created). When I go to
resource-center/reg-assoc, I get my page and the tabs, but when I go
to resource-center/affiliate, I just get the page with no tabs.
When I log in as a regular role, I don't see the menu items at all,
and if I go to resource-center/reg-assoc, I get Access Denied. Am I
doing something wrong, or is this a bug in the menu system.
Thanks.
Steve
--
[ Drupal support list | http://lists.drupal.org/ ]