0

I need to get teaser of a custom field. I used the below code that I used for body.

$fieldContent = field_get_items('node', $nodeObj, 'my_field_name');
$teaser = field_view_value('node', $nodeObj, 'my_field_name', $fieldContent[0],'teaser');
//Below line prints an empty array
print_r($teaser);
$teaser   = drupal_render($teaser);

When I try the above code for the field body it works. What the code expects from the field to display teaser? How to fix this?

| improve this question | | | | |
  • 1
    Is the field hidden in your node type's teaser display settings? – Fabian Iwand Oct 9 '15 at 8:33
  • yes it was. Changing it to 'Default'/'Trimmed' works.. Put your comment as an answer.. it deserves an upvote... – Kannan Ramamoorthy Oct 9 '15 at 8:42
2

Go to your node type's display settings for the teaser view mode and verify that the field is not hidden.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.