I want to display cms block if product has the attribute set to yes. A product may have multiple attributes set to yes, and may display multiple cms blocks. Attribute label text will be a BlockId. It may also be another proposed method. How do I see it:
<?php
if(($_product->getAttributeText('*') == "yes")){
echo $this->getLayout()->createBlock('cms/block')->setBlockID(getAttributeText())->tohtml();
}
?>
-
Yes, either you can make the above method or use another method like create array on phtml based on that one you can use that things.Dhiren Vasoya– Dhiren Vasoya2021年12月28日 11:01:41 +00:00Commented Dec 28, 2021 at 11:01
-
My method does not work, this is not the correct codescalpel– scalpel2021年12月28日 15:21:33 +00:00Commented Dec 28, 2021 at 15:21
1 Answer 1
you need to try this code.
<?php
if(($_product->getYourCustomattribute()))
{
echo $this->getLayout()->createBlock('cms/block')->setBlockID('Your_Block_Id')->tohtml();
}
?>
answered Dec 29, 2021 at 3:55
Explore related questions
See similar questions with these tags.
default