Easy method for caching for example results of a pagelist search query. We use the default caching library build in Concrete5. Depending on your server the code below will run 10 times faster when cached.
Place in controller
$ca = new Cache();
$pages= $ca->get('staticNewsList','home');
if(empty($pages) || !is_array($pages)) {
$pl = new PageList();
$pl->filterByPath('/profile');
$pages = $pl->get();
$ca->set('staticNewsList','home',$pages);
}
$this->set('pages', $pages);
Place in view
/* in VIEW list items */
if(isset($pages) && count($pages)){
foreach($pages as $cobj){
echo $cobj->getCollectionName();
}
}
also see: concrete5 documentation
Zend Cache documentation
Loading Conversation