How to use new custom field of DISPLAY SUITE in node.tpl.php (Drupal 7)


I'm right now working on one of the drupal 7 project, which is basically based on Social networking like facebook.

Where we are including one of the module Heartbeat, in which we have done some customization and create one custom field from the Display Suite module. i have made this custom field and which is working good with Heartbeat module, but now we need required to display this custom field in all the other entity like node, comments, user profile etc.. I tried hard to do it but can't get success on. Can anyone give me hint how to use those custom display suite fields in node.tpl.php file ??

Thanks in advance.

Regards, Chandresh.




In your node.tpl you have to use following code, for example field name : field_header

 <!-- For Showing only custom field's Value Use below code -->
 <h2 ><?php print $node->field_header['und']['0']['value'];?></h2>

 <!-- ========================= OR ========================= -->

 <!-- For Showing custom field Use below code , which shows custom field's value and title-->
 <h2 ><?php print render(field_view_field('node', $node, 'field_header')); ?></h2>

 <!-- ========================= OR ========================= -->

 <h2 ><?php print render($content['field_header']); ?></h2>

People are also looking for solutions to the problem: php - WHMCS, how can I run code only once


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.