Hello,
I have created a custom content type in drupal 7 with a custom field.

The custom field name is: field_management_title

What I am wondering is how I would print this custom field in my node.tpl.php file. Since I am doing some extensive theming I would like to specify where in that template file it is supposed to print.

I noticed that the page title is printed using the following code:
<?php print $title; ?>
Is there some similar code I could use to print the custom field.

Many thanks in advance

Comments

musiman’s picture

One other note, I did try <?php print $field_management_title; ?> and other similar things but I had no success with that.

nevets’s picture

The Field data extractor module is useful for this. See the examples.

keva’s picture

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

DavidoffC’s picture

I have tried pasting <?php print render($content['field_management_title']); ?> (replacing 'field_management_title' with my custom field name) into page.tpl.php but it isn't working. There's no output.

Can anyone help, please?

UPDATE: Problem solved using Views :)

herrajon’s picture

Why on earth is this so complicated.

There seems to be no thorough explanation of this.

If one wants to output a value of a field or a custom field. Just the simple barebones way.

How is it done?

print render($content['field_myfield']);

This does not work. Also Render is for HTML garbage. So that gives:

print $content['field_myfield'];

The shit is not even close to the fan.

I want to say. I have made this work and I usually do. But I can not understand the logic behind this if there is any.

-ULFURR

P.S. I have a basic understanding of PHP but that is not the problem. How things are done in drupal seem verymuch on the side.

dpovshed’s picture

Probably you may reuse solution from here
http://drupal.stackexchange.com/questions/7402/display-a-custom-field-of...

based on field_view_field() function usage.