Render a field_group programmatically


If we have a field_group defined in the field display section, this is how one can render them.

</> CopyGet raw version
  1. // This may be weird but we Do need to render the whole entity.
  2. // In this example I use profile2 entity.
  3. $prerendered_profile2 = entity_view('profile2', array($profile2_viewed), 'full');
  5. // Now we want to run our pre-rendered entity through field_group pre-rendering function (we skip all others).
  6. $prerendered_profile2_w_groups = field_group_build_pre_render($prerendered_profile2['profile2'][$profile2_viewed->pid]);
  8. // Now we have a key with a ready-to-be-rendered group.
  9. $output = render($prerendered_profile2_w_groups['group_stats']);