<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Arial">D'oh!&nbsp; That's it.&nbsp; I was passing in
a role name instead of a permission.&nbsp; I'll try it the right way and see
if that works.<br>
<br>
Thanks.<br>
<br>
Steve<br>
</font></font><br>
David Rothstein wrote:
<blockquote
 cite="mid:27ad04850811101617x21c502b0ge96e787dfc75c3e1@mail.gmail.com"
 type="cite">
  <pre wrap="">Belated reply, but maybe this will still be helpful.  I noticed that
you are using code like:
...
'access' =&gt; user_access('regular'),
...
as the access parameter for your menu items.  The user_access()
function takes a permission as input.  So in order for this code to
work correctly, you would need to have a permission called "regular"
defined on your site, and you would then have had to assign this
permission to the appropriate user roles.  Did you do either of those
things?  If not, that would explain why regular users cannot access
your menu items.

The reason I ask is that permission names normally would be phrased
more along the lines of "access regular menu items" rather than the
single word "regular"... so it looks to me like maybe you are sending
the name of your role into the user_access() function?  If so, that
won't work.

As for why you see different behavior for resource-center/reg-assoc
and resource-center/affiliate when logged in as the admin user, that
I'm not immediately sure about.

Hope this helps,
David Rothstein


On Tue, Nov 4, 2008 at 6:26 PM, Steve Edwards <a class="moz-txt-link-rfc2396E" href="mailto:killshot91@comcast.net">&lt;killshot91@comcast.net&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">No, not really.  All that did was add another tab on at
resource-center/reg-assoc..  I still get no tabs at all at
resource-center/affiliate.

Steve

Michael Prasuhn wrote:

It looks like you are not defining your MENU_DEFAULT_LOCAL_TASK
correctly. Creating a page Y with X tabs requires X+1 entries in
hook_menu().

See this example from node.module:

$items[] = array(
   'path' =&gt; 'admin/content/types',
   'title' =&gt; t('Content types'),
   'description' =&gt; t('Manage posts by content type, including default
status, front page promotion, etc.'),
   'callback' =&gt; 'node_overview_types',
   'access' =&gt; user_access('administer content types'),
);
$items[] = array(
   'path' =&gt; 'admin/content/types/list',
   'title' =&gt; t('List'),
   'type' =&gt; MENU_DEFAULT_LOCAL_TASK,
   'weight' =&gt; -10,
);
$items[] = array(
   'path' =&gt; 'admin/content/types/add',
   'title' =&gt; t('Add content type'),
   'callback' =&gt; 'drupal_get_form',
   'callback arguments' =&gt; array('node_type_form'),
   'type' =&gt; MENU_LOCAL_TASK,
);

In this case, the MENU_DEFAULT_LOCAL_TASK is actually just to define
the tab, which is the same as 'admin/content/types'.

So basically it looks if you change your 'resource-center/reg-assoc/
basic' and 'resource-center/affiliate/basic' items to MENU_LOCAL_TASK,
and create an item such as 'resource-center/reg-assoc/view' and only
give it a title "view" or some such, a weight (usually -10), and the
path 'resource-center/reg-assoc/view' and type MENU_DEFAULT_LOCAL_TASK.

I think that's what you're trying to do, let me know if that works.

-Mike



On Nov 4, 2008, at 2:28 PM, Steve Edwards wrote:



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' =&gt; 'resource-center/reg-assoc',
      'title' =&gt; t('Resource Center - Regular'),
      'description' =&gt; t('Resource center for regular and associate
members'),
      'callback' =&gt; 'resource_center_base_page',
      'access' =&gt; user_access('regular'),
      'type' =&gt; MENU_NORMAL_ITEM,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/reg-assoc/basic',
      'title' =&gt; t('Basic Information'),
      'description' =&gt; t('Basic Information'),
      'callback' =&gt; 'resource_center_basic',
      'callback argument' =&gt; 'resources_reg_assoc_basic',
      'access' =&gt; user_access('regular'),
      'type' =&gt; MENU_DEFAULT_LOCAL_TASK,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/reg-assoc/best-practices',
      'title' =&gt; t('Best Practices'),
      'description' =&gt; t('Best Practices'),
      'callback' =&gt; 'resource_center_best',
      'callback argument' =&gt; 'resources_reg_assoc_best',
      'access' =&gt; user_access('regular'),
      'type' =&gt; MENU_LOCAL_TASK,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/reg-assoc/technology',
      'title' =&gt; t('Technology'),
      'description' =&gt; t('Technology'),
      'callback' =&gt; 'resource_center_technology',
      'callback argument' =&gt; 'resources_reg_assoc_technology',
      'access' =&gt; user_access('regular'),
      'type' =&gt; MENU_LOCAL_TASK,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/affiliate',
      'title' =&gt; t('Resource Center - Affiliate'),
      'description' =&gt; t('Resource center for affiliate members'),
      'callback' =&gt; 'resource_center_base_page',
      'access' =&gt; user_access('affiliate'),
      'type' =&gt; MENU_NORMAL_ITEM,
    );
     $items[] = array(
      'path' =&gt; 'resource-center/affiliate/basic',
      'title' =&gt; t('Basic Information'),
      'description' =&gt; t('Basic Information'),
      'callback' =&gt; 'resource_center_basic',
      'callback argument' =&gt; 'resources_affiliate_basic',
      'access' =&gt; user_access('affiliate'),
      'type' =&gt; MENU_DEFAULT_LOCAL_TASK,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/affiliate/best-practices',
      'title' =&gt; t('Best Practices'),
      'description' =&gt; t('Best Practices'),
      'callback' =&gt; 'resource_center_best_practices',
      'callback argument' =&gt; 'resources_affiliate_best',
      'access' =&gt; user_access('affiliate'),
      'type' =&gt; MENU_LOCAL_TASK,
    );

    $items[] = array(
      'path' =&gt; 'resource-center/affiliate/technology',
      'title' =&gt; t('Technology'),
      'description' =&gt; t('Technology'),
      'callback' =&gt; 'resource_center_technology',
      'callback argument' =&gt; 'resources_affiliate_technology',
      'access' =&gt; user_access('affiliate'),
      'type' =&gt; 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 | <a class="moz-txt-link-freetext" href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]


__________________
Michael Prasuhn
<a class="moz-txt-link-abbreviated" href="mailto:mike@mikeyp.net">mike@mikeyp.net</a>
<a class="moz-txt-link-freetext" href="http://mikeyp.net">http://mikeyp.net</a>






--
[ Drupal support list | <a class="moz-txt-link-freetext" href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]

    </pre>
  </blockquote>
</blockquote>
</body>
</html>