I want to place a specified Static Block in my category page on my Magento site. The code should look up if a specifically named Static Block exists, and if so display the content of it. I do this on a product page absolutely fine, but it appears that the Block Cache in a category breaks it.
I am using the code
echo $this->getLayout()->createBlock('cms/block')->setBlockId("$categoryBlock")->toHtml();
Where $categoryBlock
is a generated string in the form category_bluewidget
or category_redwidget
. In the Static Blocks I have set up separate blocks called category_bluewidget
, category_redwidget
etc.
The first page I visit the code works perfectly, however the block appears to be cached and the rest of the pages show the same CMS block on them, not the one that should show.
If I go to admin and turn off Blocks HTML output
it works fine, I don't want to do that though as it will slow the site down terriibly. I am looking at just stopping this Static Block cache.
catalog/category/view.phtml
in my custom theme to place the code into