Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a block that i want to show it in a specefic content type and some urls .
i tried to add php like :

      <?php


  $match = FALSE;
  // block is visible on the content types entered here
  $types = array('product_display' => 1, 'page' => 1);
  $url = request_uri();
  if ((arg(0) == 'node') && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    $match = isset($types[$node->type]);
  }
  // block is invisible on URLs entered here
  if (strpos($url, "somewhere")) {
    $match = TRUE;
  }
  // copy paste these for additional URLs

$tids=array_keys(taxonomy_get_children(7));
foreach($tids as $tid)
 if (strpos($url, "taxonomy/term/".$tid)) {
    $match = TRUE;
    break;
  }
  return $match;
?>

the question is : is that possible to instead of using taxonomy/term/8 use wildcard or something to include all the child in this taxonomy ?

share|improve this question
    
all children of taxonomy specified term (in here 8 )? –  zhilevan Jul 20 at 12:55
    
7 is parent taxonomy and 8 is child . i want to show it in all children from 7 –  Soheil Jul 20 at 13:21

1 Answer 1

up vote 1 down vote accepted

If you want to check all children of specified term below code can help you

first load all children of it ,then check its term ids one by one

$tids=array_keys(taxonomy_get_children(8));
foreach($tids as $tid)
 if (strpos($url, "taxonomy/term/".$tid)) {
    $match = TRUE;
    break;
  }
share|improve this answer
    
also I have better solutions,but it is simple and without any big changes in your previous code. –  zhilevan Jul 20 at 13:02
    
should i put this code in my code ? –  Soheil Jul 20 at 13:12
    
i added this instead of my code . Updated my question –  Soheil Jul 20 at 13:20
    
@Soheil Then what you want now? –  zhilevan Jul 20 at 13:24
    
it's not working :) .the block doesn't show up –  Soheil Jul 20 at 13:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.