Tuesday, March 10, 2009

Restricting Block visibilty to particular taxonamy tagged pages

Hi,here i am going to show how to create a block visible to only those pages that are tagged with same taxonamy terms.As you know drupal is very powerful a little understanding on drupal can make you to do dynamic stuffs in your websites that usually take hours of coding in normal web development enviornment.

Step 1
Go to block page

Step 2
Select the block that you need to change the visibility

Step 3
Select show block on specific pages

Step 4
Choose PHP code

Step 5
Type the following codes in PHP tag

if(arg(0)=='node' && is-numeric (arg(1)))
{
$nid=arg(1);
$node=node_load ($nid);

foreach($node->taxonomy as $term)
{
if($term->name=='video')
{
return TRUE;
}
}
}
return FALSE;



In this case video is my term .Change the video with the appropriate term name from your taxonomy.

No comments: