I want to output a field collection using dl, dt and dd tags. The collection has two fields - field_heading and field_text. I want each field_heading to be a dt, each field_text to be a dd and to wrap the whole set in a dl.

I have achieved this by overriding field--my-collection--my-content-type.tpl.php and the field--my-field.tpl.php for the heading and text fields.

The problem is, a div is being generated on each item in the field collection (by the field collection module I believe). (div class="field-collection-view clearfix view-mode-full") This div wraps the heading and text elements together. The div is therefore inserted inside the dl but before the dt. This is a problem because the dt needs to be a direct child of the dl.

Is there a way to render the field collection without this div?


<dl class = 'accordion'>
<?php foreach ($items as $delta => $item){ ?>
    <?php print render($item); ?>
<?php } ?>


<?php foreach ($items as $delta => $item){
    print render($item);
} ?>


<?php foreach ($items as $delta => $item){
    print render($item);
} ?>

2 Answers 2


You need to override theme_field_collection_view theme function in your template.php .


Create a file "field-collection-view.tpl.php" which you put in your theme folder

Content of the file: <?php print $element['#children']; ?>

If you'd want it to output exactly what it does now (I know that you don't), you'd have this content:

<?php print '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>'; ?>

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.