I have CMS static block and I must show in this block individual product name.
When I am going to product page I want show name this product in a static block.
How to do this?
I have CMS static block and I must show in this block individual product name.
When I am going to product page I want show name this product in a static block.
How to do this?
in your cms block add below code
{{block type='core/template' template='YourtemplatePath/yourTemplate.phtml'}}
And in your folder create file
yourMagentoRoot/app/design/frontend/YourPackage/YourTheme/template/YourtemplatePath/yourTemplate.phtml
and add below code in yourTemplate.phtml
file
<?php
echo Mage::registry('current_product')->getName();
?>
I can't find a way to directly inject a variable to the CMS,
but you could for instance insert a custom variable to the block like {{product_name}}
, then get the block in product page:
$html = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml();
and then inject your product name:
echo str_replace("{{product_name}}",$product->getName(),$html);