I created a text field in my "content type". as I do with php to access this value? I would print it in a similar way:

 <?php print $submitted; ?>

in node.tpl.php and prevent it from being printed in an automatic way.


I put this command in the file node.tpl.php:

<?php print $field_nazionalita_1; ?>

the result is:

Array([und] => Array(
   [0] => Array(
      [value] => francia 
      [format] => 
      [safe_value] => francia

the result that I want is: francia

but only if I inserted a value in the field.

I know little php, you can help me?


You should read about the field_view_field(), something like this should work for you:

print render(field_view_field('node', $node, 'field_nazionalita_1'));
  • thanks, There is way to don't make appear the key but only value? – Antilope Jun 25 '12 at 15:20
  • I'm not sure what you mean, can you try to be a little more specific? – Cyclonecode Jun 25 '12 at 20:42

Depends what your field is called, but you can get it directly from any node object created by node_load().

Do something like this and you'll see the structure of your node object which your field will be in:

  • can I only put so? $ + name_variable? – Antilope Jun 25 '12 at 11:08
  • mmm, that's how php works. How much php experience do you have? – David Meister Jun 25 '12 at 11:10
  • I know little php, you can help me? you see above... – Antilope Jun 25 '12 at 13:04
  • yes... <?php print $field_nazionalita_1['und'][0]['value'] ?> – David Meister Jun 26 '12 at 1:33

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.