$node->type and $node problems The following doesn't work after calling the $node->type. Can someone help?

$nid = 0;
$term_1 = "";

if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))){ 
$nid = arg(1);

$node = node_load($nid);

if(true == strpos($node-&gt;type,'article'))
{   
    $result = field_view_field('node', $node, 'field_tags_test', array('default'));
    $term_name = isset($result['#items'][0]['taxonomy_term']-&gt;name) ? $result['#items'][0]['taxonomy_term']-&gt;name : ""; 
   }
 }


If I take out the inner if-statement, then it works just fine.

Thanks for any help.
strpos() returns the zero-based offset of the first occurrence of the test string. So if your string is article and the node type is article, it will return 0.

Your if statement is basically doing this check:

if (true == 0) { ...


Since 0 is a boolean FALSE in PHP the condition isn't satisfied, and the if construct is never entered.

There are a few ways you can change the if statement which basically boil down to the same thing:


if ($node-&gt;type == 'article') {
if (strpos($node-&gt;type, 'article') !== FALSE) {
if (strpos($node-&gt;type, 'article') === 0) {