This container, when combined with a Placeholder Definition will cause the referenced block to never be cached.
/**
* Yourcompany.com
*
* PHP Version 5
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @copyright 2012 yourcompany.com
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
/**
* Cache container
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
class Namespace_Module_Model_Pagecache_Container
extends Enterprise_PageCache_Model_Container_Abstract
{
/**
* Get container individual cache id
*
* Override to return false to cause the block to never get cached
*
* @return string
*/
protected function _getCacheId()
{
return false;
}
/**
* Render block content
*
* @return string
*/
protected function _renderBlock()
{
$block = $this->_placeholder->getAttribute('block');
$block = new $block;
// only needed if the block uses a template
$block->setTemplate($this->_placeholder->getAttribute('template'));
return $block->toHtml();
}
/**
* Generate placeholder content before application was initialized and
* apply to page content if possible
*
* Override to enforce calling {@see _renderBlock()}
*
* @param string &$content The content
*
* @return bool
*/
public function applyWithoutApp(&$content)
{
return false;
}
}
Posted by Mike Whitby to Magento (2012-02-16 10:51)