0

In one of my content type i am using field collection(Title, Image, Body). I am using node embed to embed node titles of certain content type in one of my content type. The issue i am facing is that whenever i am embedding a node it is not showing title instead of it displays [[nid: 2]].

I am printing individual field collection item, to print body i am using

 $section_desc =  $field_section_content_info[$section_content_id]->field_section_body[LANGUAGE_NONE][0]["value"];

i want node title to be displayed instead of [[nid: 2]]. what code should i write to display node title in field collection.

1

You are accessing the raw value of the body field in your code. I guess the functionality of replacing [[nid: 2]] comes from a text filter?

Try rendering the field with field_view_field instead. In the example below the label is also hidden by defining $display and passing that variable along to field_view_field.

$display = array('label' => 'hidden');
$section_desc = field_view_field('field_collection', $field_section_content_info[$section_content_id], 'field_section_body', $display);
  • This code works fine but it shows label of section body which i have made hidden from manage display but still it shows. – Akshay Sawant May 28 '14 at 7:47
  • I've updated the answer with code on how to hide the label. – Pontus Nilsson May 28 '14 at 7:50
  • Yes it is now working as expected but still showing blank space before the embedded node title like below. "The node embed clearly works here Demo page" – Akshay Sawant May 28 '14 at 8:33
  • The blank space probably comes from your tpl file. – Pontus Nilsson May 28 '14 at 9:07
  • Thanks @Pontus Nilsson for your answers. I used print render which shows blank space then i used drupal_render() which gives me the proper output. Thanks once again for your answer which really saved my time. – Akshay Sawant May 28 '14 at 9:19

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.