1. Home
  2. Prices
  3. Guided Tour
  4. New Shop
  5. Shop Review
  6. Ecommerce Marketing
  7. Ecommerce TV
  8. Magento Developers
  9. Portfolio
  10. Blog
  11. Contact
Home > Magento Tutorials > Creating a YouTube Video Tab

Creating a YouTube Video Tab

Posted on: 22nd Jul 2010 By: Robert Kent Leave a comment 2 Comments

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.

  • Twitter
  • AIM
  • WordPress
  • LinkedIn
  • Facebook
  • StumbleUpon
  • Technorati Favorites
  • Delicious
  • Ping
  • Digg
  • Bebo
  • Reddit
  • MySpace
  • NewsVine
  • Google Bookmarks
  • Sphinn
  • Propeller
Categories: Magento Tutorials Tags:

2 Responses to “Creating a YouTube Video Tab”

  1. M.Keegan

    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?

  2. M.Keegan

    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.

Post A Comment