0
votes

All I'm trying to do is display a CCK field on custom--node.tpl.php but it seems everything has changed in D7 and there are no documentation on this.

In Drupal 6 I did it like so:

<?php print $node->field_myfield[0]['view'] ?>

In Drupa 7 I did it like so:

<?php print render($content['field_myfield']); ?>

The problem is that this field is html formatted and I really don't want that. How can I print/echo/display a CCK field on custom--node.tpl.php with my own formatting provided by my own CSS or template file?

2

2 Answers

0
votes

If you don't want to actually render the content, you should be able to access the raw value of the field like this, depending on the type of field:

<?php print $node->field_myfield[$node->language][0]['value']; ?>
0
votes

Get the formatted value of a cck field in Drupal 7:

<?php
$node = node_load($nid);
echo field_view_value('node', $node, 'field_YOUR_FIELD', node->field_YOUR_FIELD['und'][0]);
?>

Reference: http://plusfront.com/Drupal_6_Drupal_7_tip_Get_display_value_formatted_value_of_cck_fields