title: Trying get dynamic content hole-punched through Magento's Full Page Cache
body: <p>I am using Magento Enterprise 1.10.1.1 and need to get some dynamic content on our product pages.  I am inserting the current time in a block to quickly see if it is working, but can't seem to get through full page cache.</p>
  
  <p>I have tried a variety of implementations found here:</p>
  
  <p><a href="http://tweetorials.tumblr.com/post/10160075026/ee-full-page-cache-hole-punching" rel="nofollow">http://tweetorials.tumblr.com/post/10160075026/ee-full-page-cache-hole-punching</a>
  <a href="http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/" rel="nofollow">http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/</a>
  <a href="http://magentophp.blogspot.com/2011/02/magento-enterprise-full-page-caching.html" rel="nofollow">http://magentophp.blogspot.com/2011/02/magento-enterprise-full-page-caching.html</a></p>
  
  <p>Any solutions, thoughts, comments, advice is welcome.</p>
  
  <p>here is my code:</p>
  
  <p>app/code/local/Fido/Example/etc/config.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
      &lt;modules&gt;
          &lt;Fido_Example&gt;
              &lt;version&gt;0.1.0&lt;/version&gt;
          &lt;/Fido_Example&gt;
      &lt;/modules&gt;
      &lt;global&gt;
          &lt;blocks&gt;
              &lt;fido_example&gt;
                  &lt;class&gt;Fido_Example_Block&lt;/class&gt;
              &lt;/fido_example&gt;     
          &lt;/blocks&gt;
      &lt;/global&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>app/code/local/Fido/Example/etc/cache.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;config&gt;
      &lt;placeholders&gt;
          &lt;fido_example&gt;
              &lt;block&gt;fido_example/view&lt;/block&gt;
              &lt;name&gt;example&lt;/name&gt;
              &lt;placeholder&gt;CACHE_TEST&lt;/placeholder&gt;
              &lt;container&gt;Fido_Example_Model_Container_Cachetest&lt;/container&gt;
              &lt;cache_lifetime&gt;86400&lt;/cache_lifetime&gt;
          &lt;/fido_example&gt;
      &lt;/placeholders&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>app/code/local/Fido/Example/Block/View.php</p>
  
  <pre><code>&lt;?php
  
  class Fido_Example_Block_View extends Mage_Core_Block_Template
  {
      private $message;
      private $att;
  
      protected function createMessage($msg) {
          $this-&gt;message = $msg;
      }
  
      public function receiveMessage() {
          if($this-&gt;message != '') {
              return $this-&gt;message;
          } 
          else {
              $this-&gt;createMessage('Hello World');
              return $this-&gt;message;
          }
      }
  
      protected function _toHtml() {
          $html = parent::_toHtml();
  
          if($this-&gt;att = $this-&gt;getMyCustom() &amp;&amp; $this-&gt;getMyCustom() != '') {
              $html .= '&lt;br /&gt;'.$this-&gt;att;
          } 
          else {
  
          $now = date('m-d-Y h:i:s A');
          $html .= $now;
          $html .= '&lt;br /&gt;' ;
          }
  
          return $html;
      }
  
  }
  </code></pre>
  
  <p>app/code/local/Fido/Example/Model/Container/Cachetest.php</p>
  
  <pre><code>&lt;?php
  
  class Fido_Example_Model_Container_Cachetest extends Enterprise_PageCache_Model_Container_Abstract { 
  
      protected function _getCacheId()
      {
          return 'HOMEPAGE_PRODUCTS' . md5($this-&gt;_placeholder-&gt;getAttribute('cache_id') . $this-&gt;_getIdentifier());
      }
  
      protected function _renderBlock()
      {
          $blockClass = $this-&gt;_placeholder-&gt;getAttribute('block');
          $template = $this-&gt;_placeholder-&gt;getAttribute('template');
  
          $block = new $blockClass;
          $block-&gt;setTemplate($template);
          return $block-&gt;toHtml();
      }
  
  protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false; }  
  
  }
  </code></pre>
  
  <p>app/design/frontend/enterprise/[mytheme]/template/example/view.phtml</p>
  
  <pre><code>&lt;?php echo $this-&gt;receiveMessage() ?&gt;
  </code></pre>
  
  <p>snippet from app/design/frontend/enterprise/[mytheme]/layout/catalog.xml</p>
  
  <pre><code>&lt;reference name="content"&gt;
      &lt;block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml"&gt;
              &lt;block type="fido_example/view" name="product.info.example"  as="example" template="example/view.phtml" /&gt;
  </code></pre>