This patch addes a new field to the menu which allows the view to have the menu turned off and on depending on what you need.

The case that I need this for, is that I want to add a tab to an group, and so I add a little check to make sure the node it a og node, to allow it.

if (arg(0) == 'node' && is_numeric(arg(1))) {
  $node = node_load(arg(1));

  if ($node->type == 'og') {
    return TRUE;
  }
}

This will mean the tab will only display on og type nodes.

CommentFileSizeAuthor
views_menu_php.patch.txt4.94 KBgordon

Comments

merlinofchaos’s picture

I don't think I like this. I can see the need, but you can accomplish the exact same thing by creating your own menu and linking it to the view, which gives you greater control.

I'll sit on this for awhile, and take other people's opinions.

gordon’s picture

Can you please give an example.

I think I know what you are saying, but this would mean a lot more code than just the little snippet that is required with my patch. And this would put it out of the reach of a normal admin with no development skills.

merlinofchaos’s picture

userreview module uses a construct like this:

  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $items[] = array(
      'path' => 'node/' $node->nid '/review', // this will match the 'node/$arg/review' menu item
      'access' => function_that_determines_if_node_can_be_reviewed($node)
    );
  }
gordon’s picture

I guessed that it was something like this, but as I said this then puts this out of the reach of a average site admin which can do some php for blocks, and maybe content, but developing an entire module (even just a small one) will be over/or perceived to be over their head.

merlinofchaos’s picture

Ok, I'm not going to do this. However!

I'm thinking of a patch that allows $arg to be different values:

$user
$node

So that it could at least validate that $user and $node exist. Perhaps even going so far as $node-type or some such, but that's getting pretty complex and ugly.

gordon’s picture

Yes being able to do $node-type would be great. I think this is all that I have ever done

catch’s picture

Status: Active » Closed (won't fix)