I'm using Drupal 7 with field collection module. I have the template files set up and rendered with a call to render(). However, even though the templates are executed, the output is thrown away.

This is the code in the template file

<?php trigger_error(basename(__FILE__)); //wtf(bt());die; ?>
<?php if ($element['#items'][0]['value']) { ?> gray<?php } else { ?> not-gray<?php }
//ob_end_flush();//die; ?>

The field type is list_boolean and there is output no matter what the value is (if/else). trigger_error(basename(__FILE__)) is just to check if the file is even being interpreted, which it is.

When I uncomment the line calling ob_end_flush(), the output is rendered, but the header region fails to output, clearly disrupting the output buffer stack.

Is there some kind of field collection output buffering going on that I'm unaware of? If it is so, can it be disabled?

The following is the code for my various template files.


<section id="page-content"><?php print render($content['field_content_section']);?></section>


<?php foreach ($items as $item) print render($item); ?>


<div class="sub-section<?php print render($content['field_gray_background']); ?>">
    <?php print render($content['field_section_title']); ?>
    <?php print render($content['field_content_column']); ?>


<?php trigger_error(basename(__FILE__)); //wtf(bt());die; ?>
<?php if ($element['#items'][0]['value']) { ?> gray<?php } else { ?> not-gray<?php }
//ob_end_flush();//die; ?>
  • Are you seeing any kind or error on screen?? – Sumit Madan Apr 8 '15 at 8:31
  • There are no errors on screen, in Drupal's log, or in Apache's log. Everything renders correctly (I can tell when I flush the output buffer or kill the script); however, it seems like the output buffer is not being flushed to Apache. Any suggestions are greatly appreciated. Thank you. – chaseisabelle Apr 8 '15 at 15:26
  • Before you can override a specific field template (for example field--content_section.tpl.php) I think you need field.tpl.php too. Have you installed Theme developer as this module can normally help track down template problems, etc? – Colin Shipton Apr 10 '15 at 15:30
  • Thank you, @colin-shipton. Drupal mentions that field--field_name.tpl.php will override field.tpl.php here. When they say "override" do they mean that will execute field--field_name.tpl.php instead of field.tpl.php, or do they mean it will execute field--field_name.tpl.php before field.tpl.php (sort of like an inheritance model)? I will also look into the Theme Developer module. – chaseisabelle Apr 13 '15 at 16:15
  • It means that it will execute field--field_name.tpl.php instead of field.tpl.php, but you still need field.tpl.php in your theme – Colin Shipton Apr 14 '15 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.