Skip to main content
4 of 4
edited title
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How can I show/hide a block on specific taxonomy URLs depending on term depth?

I need to show blocks on different url's.

Block1 
Should be displayed on:
branches/taxonomytermlevel1
But not on
branches/taxonomytermlevel1/taxonomytermlevel2

Block2 
Should be displayed on
branches/taxonomytermlevel1/taxonomytermlevel2
But not on
branches/taxonomytermlevel1

The terms /taxonomytermlevel1/taxonomytermlevel2 are variables (elements in some taxonomy list)

What is the most easiest way to do this? I think a php script in the block display visibility setting would be the trick and so I tried some code there but I did not succeed.

Some code I have now is e.g.:

<?php
if (empty(arg(3))) {
  return TRUE;
}else {
  return FALSE;
}
?>

Any suggestions?

Justme
  • 1.3k
  • 1
  • 10
  • 30