Render a field view value in your custom module

Published on 3 September 2012 - 6:20am

In a theme's node.tpl.php, we can easily render a field view using Drupal's render().

For example, we have a field name field_integer with the label My integer. To display the field in the node.tpl.php, we can just call it out using render($content['field_integer']);, which will display like the following (Assuming it is the default manage display setting for the field):

My integer:3 200

However, what if you want to render the field in your custom module? You won't be able to use render($content['field_name']).

Programmatically creating / deleting / modifying field-collection item for a node

Published on 10 May 2012 - 8:19pm
If you have use Field-Collection module (http://drupal.org/project/field_collection), you would know how useful it is when you need to create a node with grouped value. However, due to how field-collection utilizes Entity API, you will not be able to programmatically update its value directly. Here's a great example on how you could do so