Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


  $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

foreach($tids as $tid)
 if (strpos($url, "taxonomy/term/".$tid)) {
    $match = TRUE;
  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 '14 at 12:55
7 is parent taxonomy and 8 is child . i want to show it in all children from 7 – Soheil Jul 20 '14 at 13:21
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

foreach($tids as $tid)
 if (strpos($url, "taxonomy/term/".$tid)) {
    $match = TRUE;
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 '14 at 13:02
should i put this code in my code ? – Soheil Jul 20 '14 at 13:12
i added this instead of my code . Updated my question – Soheil Jul 20 '14 at 13:20
@Soheil Then what you want now? – zhilevan Jul 20 '14 at 13:24
it's not working :) .the block doesn't show up – Soheil Jul 20 '14 at 13:25

Your Answer


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.