<config>
<placeholders>
<namespace_module>
<block>namespace_module/something</block>
<placeholder>NAMESPACE_MODULE_UNIQUE_STRING</placeholder>
<container>Namespace_Module_Model_Pagecache_Container</container>
<cache_lifetime>86400</cache_lifetime> <!-- never gets used -->
</namespace_module>
</placeholders>
</config>
Boilerplate FPC No-Cache Container
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;
}
}
Using Differing Setup Classes In One Module
On occasion you may have a module which requires both EAV and flat resource setup classes, in this situation you can instantiate a setup class as this note shows.
/**
* 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
*/
/**
* A description of the controller
*
* @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_Adminhtml_SomeController extends Mage_Adminhtml_Controller_Action
{
/**
* Control access to this controller via ACL
*
* @return bool
*/
protected function _isAllowed()
{
return Mage::getSingleton('admin/session')->isAllowed('the/acl/xpath');
}
/**
* Index action
*
* @return void
*/
public function indexAction()
{
$this->_title($this->__('Module'))->_title($this->__('Something'));
$this->loadLayout();
$this->_setActiveMenu('namespace_module/something');
$this->_addBreadcrumb(Mage::helper('namespace_module')->__('Module'), Mage::helper('namespace_module')->__('Something'));
$this->renderLayout();
}
}
Enabling The Profiler
In index.php uncomment this line:
#Varien_Profiler::enable();
In the admin enable the profiler output:
Set System > Configuration> Advanced > Developer >Debug > Profiler to yes
To enable the Zend_Db profiler add the following node to your app/etc/local.xml file. It can be added into your database connection configuration. The output will also be displayed if the admin setting above is set to true.
No comments:
Post a Comment