0

I am using Field Group to group my fields. Purpose of this is to have better control when rendering them inside the node.tpl.php file. Specifically, I want to designate in the node.tpl.php where in the html document I want specific groups of fields rendered, while sorting fields and designating what fields belong to what group inside the UI.

Do you think Field Group is a good way of achieving this? If grouping fields using Field Group, how do you then render that group in the template file?

Edit: I am steering towards template solutions, avoiding the likes of Panels and DS.

3 Answers 3

3

I ended up using hide() on content elements I wanted place independently before print rendering the rest of content. As I have learned the way drupal renders/prints makes this very easy. Example:

<?php hide($content['product:title']); ?>
<div>
  <?php print render($content); ?> <!-- $content['product:title'] is not output -->
</div>
<div>
  <?php print render($content['product:field_image']); ?>
</div>
1

In Drupal 7 it's easy to render group or individual field of groups in template file for theme

If want to render full group with subgroup then print render($content['group_cruiseline_ships'];

If want to render only subgroup then print render($content['group_shop']['product'];

If want to render only specific field of subgroup or group then print render($content['group_shop']['product']['field_keyboard'];

thanks.

0

I use field groups' div type with display suite to stack my fields for better CSS control. No need to go into template files.

Here you can see how I have wrapped the fields in field groups with divs https://www.evernote.com/shard/s272/sh/976bd05c-8b35-41d3-aad1-107ede26de09/a0d68b931e6093b9ea27a1cd5d952420

Here is the html-code: https://www.evernote.com/shard/s272/sh/0e695fad-6a47-4249-9110-2c79a1999c73/aa7f981b606e977a38b70d61cf94dd6c

1
  • 1
    Thanks for the input, but I am steering towards template function solutions. Commented Apr 2, 2013 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.