1

I've created a fieldable panel pane that has two fields, a title and a body. My template file looks like this:

<div class="sidebar-pane">
    <h2 class="pane-title">
        <?php print render($content['field_pane_title']); ?>
    </h2>
    <div class="pane-content">
        <?php print render($content['field_body']); ?>
    </div>
</div>

This seems fairly basic. Now, when I actually add one of these panes to a page, this is the DOM that is spit out:

<div class="sidebar-pane">
    <h2 class="pane-title"></h2>
    <h3 class="field-label"></h3>
    Test Pane   

    <div class="pane-content">
        <h3 class="field-label"></h3>

        <p>This is a test body.</p>
    </div>
</div>

Ignoring the fact that it's printing out empty field-label elements, why is the pane-title field being printed outside the pane-title h2 element? Is there a better way to be doing this? Thanks!

0

Ignoring the empty field-labels was a problem! The issue was with those field labels, which were generated by the Fences module. They were somehow causing the h2 to close too early.

I ended up modifying the module myself, so that the template checks if a field label exists before adding it to the DOM.

I also ended up finding an issue on the module's issue page which has a patch to fix it directly, in case anyone is interested: https://www.drupal.org/node/2605808

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.