Drupal: How to display block only on nodes of certain content type?

Edit your block and select "Show if the following PHP code returns TRUE (PHP-mode, experts only)"  and insert following php code:

<?php

//Read URL
$path=$_GET['q'];

//If URL is node page

if ( strpos($path,'node')===0){
//Parse URL to get nid
$links=explode("/",$_GET['q']);
$nid=$links[1];

//Load node

$node=node_load($nid);

//Display block only if node is of certain content type
if($node->type=='YOUR CONTENT TYPE'){
return TRUE;
}
}

return FALSE;
?>
Tags: