8

Starting to think I've lost my mojo...

Both blocks named before_body_end and after_body_start are of type core/text_list. However, the following layout xml:

<layout>
    <default>
        <reference name="before_body_end">
            <block type="remarketing/ecjs" name="remarketing_ecjs" as="remarketing_ecjs" />
            <block type="remarketing/modal" name="remarketing_modal" as="remarketing_modal" />
        </reference>
    </default>
</layout>

Does not output the child blocks in the reference. If I swap the before_body_end for after_body_start, the blocks render as expected

Both child blocks extend from Mage_Core_Block_Text.

Any ideas why? I think I have Friday-osis...

philwinkle
  • 35,751
  • 5
  • 91
  • 145

1 Answers1

23

This may sound stupid, but I'll ask anyway: did you double-check that the main template file (e.g. 1column.phtml) of your theme does echo $this->getChildHtml('before_body_end')?

On a vanilla CE 1.7.0.2, this code

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="after_body_start">
            <block type="core/template" name="test1" template="test.phtml" />
        </reference>
        <reference name="before_body_end">
            <block type="core/template" name="test2" template="test.phtml" />
        </reference>
        <reference name="content">
            <block type="core/template" name="test3" template="test.phtml" />
        </reference>
    </default>
</layout>

outputs my test block three times.

Reasons why it may show up in after_body_start but not in before_body_end from the top of my head:

  1. Block is not echoed in the used main .phtml file.
  2. Some code unsets before_body_end during building the page.
  3. Some code unsets the children of before_body_end during building the page.

I assume a modified page.xml (so that the block isn't declared) or a caching issue can be ruled out given that it's you. ;-)

Matthias Zeis
  • 7,697
  • 3
  • 32
  • 50
  • 2
    Unfortunately I've checked all of those things. echo $this->getChildHtml('before_body_end') is present... page.xml is unmodified. I will keep digging. I refuse to let this one beat me! :) – philwinkle Sep 22 '13 at 10:53
  • 2
    The answer in the end was a modified enterprise/default/layout/page.xml file which renamed before_body_end to closure. It was a Friday and for some reason I didn't think of enterprise/default - thanks for jogging my memory! – philwinkle Oct 23 '13 at 18:27
  • 1
    @Matthias Zeis i have used "after_body_start" and now it's working for me. Thanks – Sarfaraj Sipai Jan 23 '18 at 08:56