How to determine the current node type?
sisyphus - April 13, 2008 - 02:42
suppose i create a block and want to print out something when the content is showing a certain type of node, say, blog. how to code it in the block? i wrote this:
<?php
print $node->type;
?>thanks a lot.

looks like the right code.
looks like the right code. where did you put the print statement?
Blocks do not have a $node
Blocks do not have a $node variable, if you want the block to do something based on the current node you need something like
<?phpif ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
if ( $node->type == 'xyz' ) {
// Do something for nodes of type 'xyz'
}
}
?>
Thanks for the tip.
Thanks for the tip, nevets.