Hi!
I have a problem with block visibility.
The thing is that I have a glossary "Advices" and several terms in it. Also I've made a special type of content "Advice" special for this glossary and menu block with links to tems of glossary "Advices".
How can I tune up this menu visibility settings to make it visible only for pages with advices.
This pages have following URLs:

node/2 - main page of advices section (synonim: advices)

advices/building - list of advices accroding to one of the advices glossary term (synonim: taxonomy/term/37)
advices/equipment - list of advices accroding to one of the advices glossary term (synonim: taxonomy/term/38)

node/20 - one of the articles linked to building term (no synonim)
comment/reply/20 - page with comment form for this article (no synonim)

So I need to set up visibility of custom menu block only for this type of pages. But it doesn't work for comments. May be there is a simpler decision for this problem?

I have the following code in block visibility settings field:

<?php
  $match = false;
  
  if ((arg(0) == 'node') && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ( $node->type == "advice" ) {
      $match = true;
    }
  }
  if (substr($_SERVER["REQUEST_URI"], 0, 8) == '/advices') {
    $match = true;
  }
  return $match;
?>

P.S. Sorry for my english :)

Comments

nevets’s picture

Is node 20 of type advice? If yes you could try this

<?php
  $match = false;
 
  if ((arg(0) == 'node') && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ( $node->type == "advice" ) {
      $match = true;
    }
  }
  if ((arg(0) == 'comment') && arg(1) == 'reply' &&  is_numeric(arg(2))) {
    $node = node_load(arg(2));
    if ( $node->type == "advice" ) {
      $match = true;
    }
  }
  if (substr($_SERVER["REQUEST_URI"], 0, 8) == '/advices') {
    $match = true;
  }
  return $match;
?>
Stutzer’s picture

Thanks a lot! It really works. But is that the only one decision?
It's not very smiple :)