Creating a YouTube Video Tab
For this tutorial, you will need the modern theme installed.
What we are going to do is to add an attribute to our attribute set where you can embed the youtube video code. This will then display on the front end of the website for your products.
The files you will need to create/edit are:
- app/design/frontend/default(or base)/default/catalog/products/view/youtube.phtml – create
- app/design/frontend/default(or base)/modern/catalog.xml – edit
First of all create your attribute – we’ll make it a textarea and call it youtube. Give it the settings shown in the image. We’ll then add it to our attribute set.
(Note: I was working on a 1.3 version of magento and due to a small bug I needed to use the description tab and block – it should work for you if you created the new files. )
Secondly you need to paste the following code into your youtube.phtml file.
<?php if ($this->getProduct()->getYou_tube()) { echo "<div>".$this->getProduct()->getYou_tube()."</div>"; } ?>
Lastly all you need to do is set up a new tab in your xml file. Paste in the following code.
<action method="addTab" translate="title" module="catalog"><alias>description</alias><title>Featured Video</title><block>catalog/product_view_description</block><template>catalog/product/view/description.phtml</template></action>
That’s it! Now all you have to do it paste in the embed code from youtube and you can enjoy a nice product video in a tab! Happy days.



Not sure what I’ve done wrong, but I receive the following error:
Invalid method Mage_Catalog_Block_Product_View::addTab(Array(
[0] => description
[1] => Featured Video
[2] => catalog/product_view_description
[3] => catalog/product/view/description.phtml
)
)
Any ideas what’s gone wrong?
Managed to solve the problem. To work with Magento 1.4.0.1 the code for the xml file must be:
youtubeFeatured Videocatalog/product_view_descriptioncatalog/product/view/youtube.phtml
This should be placed within the “product_view_tabs” block in catalog.xml.
Hi
this is fanstanstic but will this work in 1.4.1.1
To get it working on 1.5.1 you need to change the code in catalog.xml to:
YoutubeFeatured Videocatalog/product_view_descriptioncatalog/product/view/youtube.phtml