Unable to print CCK field in template in Drupal
I'm trying to print CCK field in my node.tpl.php -file like this;
print $node->field_name_here[0]['view'];
But when I navigate to that page, I can't see the contents.
Even when i use print_r($node);
I can't see any info about the variable. Drupal only renders everythi开发者_StackOverflowng else in node.tpl.php -file.
BUT... if I stop the execution of node.tpl.php by putting die();
anywhere after the print_r()
or
print $node->field_name_here[0]['view'];
the CCK field / variable renders as it should.
It's not issue with permission since I have allowed all users to see the contents of these fields. I even tried to disable and uninstall CCK field permissions -module, but still can't print CCK fields in my template properly.
What am I missing here?
$node = (object) $node; $node = node_build_content($node, $teaser, $page); $content = drupal_render($node->content); // Allow modules to modify the fully-built node. node_invoke_nodeapi($node, 'alter', $teaser, $page); return $node;
Just pass your loaded node with above lines of code .This will return you the [view] of the node.
check in the content type display tab. example.com/admin/content/node-type/{content-type}/display
There is a good chance that the display for the field you are trying to work with is set to none the checkbox of "exclude" is checked.
shouldnt it be the following?
print $node->field_name_here[0]['value'];
instead? (value instead of view) - In scripts i acces them like that and it's also shown on the node's devel tab
精彩评论