I wrote the following code
<?php $appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
$_headerImage1 = $this->getLayout()->createBlock('cms/block')->setBlockId('movie')->toHTML();
$_headerImage2 = $this->getLayout()->createBlock('cms/block')->setBlockId('music')->toHTML();
foreach ($appliedFilters as $item) {
if ($item->getFilter()->getRequestVar() == 'my_attribute1') {
echo $_headerImage1;
}
else
if ($item->getFilter()->getRequestVar() == 'my_attribute2') {
echo $_headerImage2;
}
}
?>
It worked fine. But, if the first and second attributes are selected at the same time - on page appears two static blocks.
I need - when you select the second attribute - displaying only second static block.
Perhaps the use of a specific space for static block or resctict first static block if selected second attribute.
In any case , I do not know how to do it.
Please help!
UPDATED
I found another case.
<?php $_filters = Mage::getSingleton('catalog/layer')->getState()->getFilters();
$_headerImage = $this->getLayout()->createBlock('cms/block')->setBlockId('static_block_0')->toHTML();
if (is_array($_filters)) {
foreach ($_filters as $_filter) {
if ($_filter->getRequestVar() == 'my_attribute_0') {
switch ($_filter->getRequestVar()) {
case 'my_attribute_1' :
$_headerImage = $this->getLayout()->createBlock('cms/block')->setBlockId('static_block_1')->toHTML();
break;
case 'my_attribute_2' :
$_headerImage = $this->getLayout()->createBlock('cms/block')->setBlockId('static_block_2')->toHTML();
break;
}
}
}
}
echo $_headerImage;
?>
But it not worked.