[TYPO3-mvc] Caching framework inside extbase extension

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Dec 30 17:56:43 CET 2010


Hey,

> My next step was to store the result of $this->view->render() instead
> and push it with $this->result->setContent().
>
> This works fine, my only problem is, that the "normal" view output is
> also rendered, which gives me some translated error messages from my
> template that the necessary objects are empty.

why don't you simply return the rendered/cached view in your controller 
method? This will also prevent the view to be rendered again.

if 
($this->cacheInstance->has(hash('md5','category'.$demand->getCategory()))) {
    $content = $this->cacheInstance->get(hash('md5', 
'category'.$demand->getCategory()));
} else {
    $references = $this->referenceRepository->findDemanded($demand);
    $this->view->assign('demand', $demand);
    $this->view->assign('categories', $this->categoryRepository->findAll());
    $this->view->assign('references', $references);

    $content = $this->view->render();

    $this->cacheInstance->set(hash('md5', 
'category'.$demand->getCategory()), $content , array('type' => 
'references'));
}

return $content;

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list