cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Generic CMS Page into product Tab

Adding Generic CMS Page into product Tab

Good day,

 

I am not sure how to correctly pose this question, but I have searched for days now, so when Mr Google fails me, the community are always great!

 

What I am wanting to do is create a "block reference" that resides in a Product Tab.  

 

The reason for this is so I can se a widget and select this content to be shown on multiple products.  I am currently using the detailed description however the obvious problem is that if I need to make a change, I need to do that 100 times, and it is a little boring and time consuming.

 

I thought it could be possible to define a "Block reference" within a .phtml page, and then call that as below:

 

<action method="addTab" translate="title" module="catalog"><alias>overview</alias><title>Overview New</title><block>tag/product_list</block><template>catalog/product/custom_overview.phtml</template></action>

 

However I have been unsuccessful so far with all my attempts to do this.

 

I would love to hear other peoples ideas / solutions on how to achieve this.


Many many thanks in advance.

 

Regards,

 

Ian

1 REPLY

Re: Adding Generic CMS Page into product Tab

Hi Ian,

 

we have done this in the past with static block matching. You will need to create each of your static blocks and have a product attribute that ties them with the product.

 

So your bank of static blocks will have identifiers like so, whereproduct_name_goes_here matches the Product Name attribute:

 

option_help_product_name_goes_here

 

and you have an attribute that is a text field to match on, in this case I am using product name but you can use anything.

 

Your phtml template will need to have the logic to do the matching.

 

<?php
// Replace any spaces or slashes in the product name with underscores
$identifier = str_replace(array(' ', '/'),array('_', '_'), strtolower($_product->getName()));
// Create the static block
$layoutBlock = $this->getLayout()->createBlock('cms/block')->setBlockId('option_help_' .$identifier);
?>

You will then need to echo this out, like this:

<?php echo $layoutBlock->toHtml(); ?>

 

Let me know if that works for you.

Gareth.

If you're happy with this response - please mark it as a solution!
Magento Certified Front-end Developer | www.iweb.co.uk