2

I would like to theme a group of fields that belong to a content type. For example to position all of them at a certain area in the page.

I want to do this in conjunction with the field_group module

I know that it is possible to theme an individual field, by overriding field.tpl.php in your own theme, along with CSS as required. And I have done this successfully.

However I'd like to know if there is something like field-group.tpl.php which I can override in my own theme, similar to how I have done for field.tpl.php.

When editing the field group settings in the Content Type, <div> can be specified for a field group, as well as CSS classes. So I create a field group and specify these things and then add some fields to belong to my field group. However, when I look at the html source output for content of this content type, I cannot see anywhere this extra div is defined nor its groupname. Therefore I don't know how to theme it. Please advise.

  • Like you say, there is the ability to add classes to your field groups. You can use those for styling. This question very much depends on your theme also because it is possible your theme is making it so that your field groups and fields are not printing out all their classes & ids. – rooby Oct 8 '13 at 12:38
2

I know you mentioned wanting to use the field_group module, but I don't immediately see the need.

If the goal is to position a set of fields all together, why not override your node.tpl.php file, calling it node--my-content-type.tpl.php and then somewhere within it do something along the lines of:

<div id="field-group">
  <?php print render($content['my_field1']); ?>
  <?php print render($content['my_field2']); ?>
  <?php print render($content['my_field2']); ?>
</div>

That way they can A) be positioned by positioning #field-group, as well as allowing you to theme each field in their own field.tpl.php file.

0

First check: make sure your putting these field groups in on the "Manage Display" tab of your content type, not the "Manage Fields". "Manage Fields" only affects the node edit form, "Manage Display" field groups should show up on the page with your specified class/wrapper etc.

Second check: Are you looking at the right view_mode? Field groups will show up on whatever view mode you have them set on.

Last thing I'd look at, if you're doing any preprocessing of the $content variable it can muck up settings you put into the "Manage Display" tab where the field_groups are. You can dpm($variables['content']); in your node_preprocessor at different points to see if anything is messing with it.

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.