2

I am overriding the node template for a custom content type, say node-custom.tpl.php. The content type have some fields that I want to show in columns like this :

|Label1|Data1|
|Label2|Data2|
|Label3|Data3|
|Label4|Data4|

If I use render($content['field_custom_data']) both the data and the label are drawn. I know how to hide the label from the render using the content type display configuration but I need a solution for the label. The site is multilanguage if that matters.

1
  • I think field_get_items is a good way to go here, I just don't have time to properly answer below. It allows you to theme the individual custom data parts as you want above. Commented Jun 25, 2013 at 15:27

1 Answer 1

0

This code will print all labels .

     $entity_type = 'node';
     $bundle_name = 'CUSTOM'; //machine name of your content type


  foreach ($node as $key => $value) {

        $field_name = $key;

        $info = field_info_instance($entity_type, $field_name, $bundle_name);

        $label = $info['label'];

        print $label;
        print "<br>";
   }

You can modify it according to your need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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