Magento hole punch won't load child blocks when cached
<p>I am hole punching Magentos FPC. I have a block that loads other blocks (banners) depending on parameters set in the users session. The code all works and the banners dynamically load if I add</p>

<pre><code>$layout = Mage::getSingleton('core/layout');
$layout-&gt;getUpdate()-&gt;load('default');
$layout-&gt;generateXml()-&gt;generateBlocks();
</code></pre>

<p>to the .phtml template but without it the blocks only load for the initial (un-cached) page. The second and all proceeding (cached) requests fail to load the blocks using $this->getChildHtml or $this->getBlockHtml. Also when I load the core layout this breaks the core messaging and seems like a hack.</p>

<p>Here is my app/design/frontend/base/default/layout/amsh_splitpay.xml</p>

<pre><code>&lt;layout&gt;
&lt;default&gt;
    &lt;reference name='root'&gt;
        &lt;block type="splitpay/banner" name="splitpay.banner" template="splitpay/banner.phtml"&gt;
            &lt;action method="unsetData"&gt;&lt;key&gt;cache_lifetime&lt;/key&gt;&lt;/action&gt;
            &lt;action method="unsetData"&gt;&lt;key&gt;cache_tags&lt;/key&gt;&lt;/action&gt;

            &lt;block type="zblocks/block" name="page_top_splitpay_zblock"&gt;
                &lt;action method="setPosition"&gt;
                    &lt;position&gt;page-top-splitpay&lt;/position&gt;
                &lt;/action&gt;
            &lt;/block&gt;

            &lt;!-- Created custom zblock for page top --&gt;
            &lt;block type="zblocks/block" name="page_top_zblock"&gt;
                &lt;action method="setPosition"&gt;
                    &lt;position&gt;page-top&lt;/position&gt;
                &lt;/action&gt;
            &lt;/block&gt;
        &lt;/block&gt;
    &lt;/reference&gt;
&lt;/default&gt;
&lt;/layout&gt;
</code></pre>

<p>in phtml</p>

<pre><code>&lt;?php

$sp = Mage::getSingleton("customer/session")-&gt;getSplitpayOptions();

$block = $this-&gt;getBlockHtml('page_top_splitpay_zblock',false);
if(!empty($sp) &amp;&amp; !empty($block)){?&gt;
&lt;div class="zblock container hide-for-small-only"&gt;
    &lt;div class="row"&gt;
        &lt;div class="large-12 columns"&gt;
            &lt;?php echo $block; ?&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php
} else {
    if ($this-&gt;getBlockHtml('page_top_zblock',false)): ?&gt;
    &lt;div class="zblock container hide-for-small-only"&gt;
        &lt;div class="row"&gt;
            &lt;div class="large-12 columns"&gt;
                &lt;?php echo $this-&gt;getBlockHtml('page_top_zblock',false);
?&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;?php endif;
}
?&gt;
</code></pre>

<p>in Model/Container/Banner.php</p>

<pre><code>&lt;?php

class Amsh_SplitPay_Model_Container_Banner extends Enterprise_PageCache_Model_Container_Abstract
{

protected function _getCacheId()
{
    $cacheId        = $this-&gt;_placeholder-&gt;getAttribute('cache_id');
    $cookieCustomer = $this-&gt;_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
    return 'AMSH_SPLITPAY_BANNER_CACHE_' . md5($cacheId) . '_' . $cookieCustomer;
}


protected function _renderBlock()
{
    $block = $this-&gt;_getPlaceHolderBlock();
    // only needed if the block uses a template
    $block-&gt;setTemplate($this-&gt;_placeholder-&gt;getAttribute('template'));
    Mage::dispatchEvent('render_block', array(
        'block'       =&gt; $block,
        'placeholder' =&gt; $this-&gt;_placeholder
    ));

    return $block-&gt;toHtml();

}

protected function _saveCache($data, $id, $tags = array(), $lifetime = null)
{
    return false;
}
public function applyWithoutApp(&amp;$content)
{
    return false;
}

}
</code></pre>