i use the Zend_Layout and have some placeholder areas.
I fill thouse placeholders with this code:
$view->placeholder('Login')->set( $view->action('simple','Login'));
The most of this Holders are cacheable and i've develop a
Helper_Action and i'll found a better solution.
Thanks a lot
Marcel
----
<?php
require_once 'Zend/View/Helper/Action.php';
class Default_View_Helper_Action extends Zend_View_Helper_Action
{
public function action($action, $controller, $module = null, array
$params = array())
{
$sCacheString = md5($controller . '_' . $action);
if ( file_exists(__CACHE_DIR__ . '/controllers/zend_cache---' .
$sCacheString) && ($return = $this->_getCache()->load(
$sCacheString)) )
{
return $return;
}
$return = parent::action($action, $controller, $module, $params);
$front = Zend_Controller_Front::getInstance();
$oAction = $front-
>getPlugin('Zend_Layout_Controller_Plugin_Layout')-
>getLayoutActionHelper()->getActionController();
if (property_exists($oAction, 'aCacheable'))
{
$aCache = $oAction->aCacheable;
if (isset($aCache[strtolower($action)]) &&
$aCache[strtolower($action)])
{
$oCache = $this->_getCache();
$oCache->save($return, $sCacheString);
}
}
return $return;
}
private function _getCache()
{
$frontendOptions = array(
'lifetime' => 7200,
'automatic_serialization' => true
);
$backendOptions = array(
'cache_dir' => __CACHE_DIR__ . 'controllers/'
);
$oConfigCache = Zend_Cache::factory('Core',
'File',
$frontendOptions,
$backendOptions);
return $oConfigCache;
}
}
没有评论:
发表评论