I need to cache CakePHP elements. But my elements differ with parameters.
myElement takes a parameter named $type.
When $type changes contents of my element changes.
I call my element like this:
echo $this->element(‘myElement’, array(‘type’ => 2), array(‘cache’ => true));
in another page like this:
echo $this->element(‘myElement’, array(‘type’ => 3), array(‘cache’ => true));
When I enable caching by increasing Debug mode to 2, both of the elements give me the same output. Is it possible to cache different versions of one element ?
The
'cache'key can take an array withconfigandkey. Setting thekeyto a unique name (appending the type in the name) should make it unique.If the elements do not have much in common, it may just be easier to have different element files for each.
$this->element('myElementType3'); $this->element('myElementType2');etc.