Hello,
In one of my blocks, I use the function node_load().
I see a field with its suffix and in the proper format.
The code I use:
<?php
print $node->field_cylindree[0]['value'];
?>
Example 1:
Result:
50.0
Desired result:
50 cm3
Example 2:
Result:
49.7
Desired result:
49.7 cm3
Thank you in advance for your help!
Comments
Comment #1
markus_petrux commentedIf you want to use the prefix/suffix defined in field settings, the you need to use content_fields() function to retrive the $field information, as in the example that we already saw here: #637636: How to print the field label in node templates.
The prefix/suffix settings are there, just use var_dump($field) or equivalent to figure out the structure of the $field array returned by content_fields().
Comment #2
Clément commentedThank you for your reply.
I do not understand how to use the content_fields()
I tried like this but without success:
I also looked at the link but it does not help me.
Is this you could explain how this function works or give me a link that explains in detail how it works?
Comment #3
markus_petrux commentedYou need to explore the contents of the $field array returned by content_fields(). I prefer to help you learn how to fish, rather than giving you this particular fish, so please re-read my second statement in #1.
Now, see what the $field array contains. This should help you figure out how to resolve other things that you may need to do.
Comment #4
Clément commentedThank you very much for your response.
These you should put (for suffix):
You're right not giving me the answer because it would not have served for more. Thanks to your code, I can see the whole picture and thus understand what to do. It will make me much service for more ...
Another big thank you!