<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Redstage Magento Blog &#187; layout XML</title>
	<atom:link href="http://www.redstage.com/magento/blog/tag/layout-xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redstage.com/magento/blog</link>
	<description>Tips, Tricks &#38; News about Magento E-commerce</description>
	<lastBuildDate>Thu, 13 Oct 2011 22:27:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Add Video to Products in Magento</title>
		<link>http://www.redstage.com/magento/blog/2010/03/17/how-to-add-video-to-products-in-magento/</link>
		<comments>http://www.redstage.com/magento/blog/2010/03/17/how-to-add-video-to-products-in-magento/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 16:47:44 +0000</pubDate>
		<dc:creator>Antonio David</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jwplayer]]></category>
		<category><![CDATA[layout XML]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.redstage.com/magento/blog/?p=231</guid>
		<description><![CDATA[Adding a video to a product greatly enhances the online shopping experience.  The out-of-the-box Magento package doesn&#8217;t support video.  This How-To shows just how to do that.  We&#8217;ll be able to either (1) drop in HTML embed code from sites like YouTube, or (2) use an FLV file that we provide.
This article [...]]]></description>
			<content:encoded><![CDATA[<div id='dd_left'><ul><li class='li_vertical'><iframe src='http://api.tweetmeme.com/button.js?url=http://www.redstage.com/magento/blog/2010/03/17/how-to-add-video-to-products-in-magento/&amp;source=&amp;style=normal' height='61' width='50' frameborder='0' scrolling='no'></iframe></li></ul></div><p>Adding a video to a product greatly enhances the online shopping experience.  The out-of-the-box Magento package doesn&#8217;t support video.  This How-To shows just how to do that.  We&#8217;ll be able to either (1) drop in HTML embed code from sites like YouTube, or (2) use an FLV file that we provide.</p>
<p>This article assumes you have the jQuery Javascript library installed and have &#8220;jQuery.noConflict()&#8221;&#8216; set up.  If you don&#8217;t have jQuery.noConflict(), then simply replace instances of &#8220;jQuery&#8221; with &#8220;$&#8221;.  If you don&#8217;t have this library, <a title="Download jQuery" href="http://jquery.com/">download jQuery here</a>.</p>
<p>Here&#8217;s the sequence of steps we&#8217;re going to take:</p>
<ol>
<li>Create a product attribute for the video code</li>
<li>Assign the newly created attribute to an attribute set</li>
<li>Modify the template files</li>
<li>Obtain and upload a copy of the free JWPlayer</li>
<li>Add video to a product using HTML embed code or using an FLV file</li>
</ol>
<p><strong>1. Create a product attribute for the video code.</strong></p>
<p>Log in to your Magento Admin Panel.  Navigate to Catalog &gt; Attributes &gt; Manage Attributes.  Click on the &#8220;Add New Attribute&#8221; button found close to the top-right hand corner of the screen.  The first tab that&#8217;s open is the *Properties* tab.  You are presented with lots of textboxes and dropdowns.  Here&#8217;s what to fill them in with (you can also <a href="http://redstage.com/magento/blog/article-images/step-1-create-attribute.jpg" target="_blank">view this screenshot</a>):</p>
<p><a href="http://redstage.com/magento/blog/article-images/step-1-create-attribute.jpg" target="_blank"><img class="alignnone" src="http://redstage.com/magento/blog/article-images/step-1-create-attribute-thumb.jpg" alt="" width="93" height="200" /></a></p>
<p>Attribute Properties</p>
<p>- Attribute Code: video<br />
- Scope: Global<br />
- Catalog Input Type of Store Owner: Text Area<br />
- Default Value: [leave blank]<br />
- Unique Value: No<br />
- Values Required: No<br />
- Input Validation for Store Owner: None<br />
- Apply To: All Product Types</p>
<p>Frontend Properties</p>
<p>- Use in quick search: No<br />
- Use in advanced search: No<br />
- Comparable on Front-end: No<br />
- Use in Layered Navigation: No<br />
- Use in Search Results Layered Navigation: No<br />
- Use for Price Rule Conditions: No<br />
- Position: 0<br />
- Allow HTML-tags on Front-end: Yes<br />
- Visible on Product View Page on Front-end: No<br />
- Used in product listing: No<br />
- Used for sorting in product listing: No</p>
<p>Then navigate to the *Manage Label / Options* tab.  You only have to fill in the &#8220;Admin&#8221; value, and for this use &#8220;<strong>Video</strong>&#8220;.  This can be changed later if you need to.</p>
<p>Click the &#8220;Save Attribute&#8221; button to save the attribute.</p>
<p><strong>2. Assign the newly created attribute to an attribute set (likely Default)</strong></p>
<p>While still in the Admin Panel, navigate to Catalog &gt; Attributes &gt; Manage Attribute Sets.  From the right-hand column, labeled &#8220;Unassigned Attributes&#8221;, drag our new video attribute to the &#8220;General&#8221; group found in the middle column.</p>
<p>Click &#8220;Save Attribute Set&#8221; button to save the attribute set.</p>
<p><strong>3. Modify the template files</strong></p>
<p>You&#8217;ll need to use a text-editor and FTP client.</p>
<p><strong>3a. video.phtml</strong></p>
<p>Create a file with these contents:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;?</span>php
$_product <span style="color: #339933;">=</span> $this<span style="color: #339933;">-&gt;</span>getProduct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;?</span>php <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> $video <span style="color: #339933;">=</span> $_product<span style="color: #339933;">-&gt;</span>getVideo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span>Product Video<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;products&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;?</span>php <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> file_exists<span style="color: #009900;">&#40;</span> getcwd<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> .<span style="color: #3366CC;">'/skin/frontend/[your-package]/[your-theme]/videos/'</span>. $video <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;mediaspace&quot;</span><span style="color: #339933;">&gt;&amp;</span>nbsp<span style="color: #339933;">;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
jQuery<span style="color: #009900;">&#40;</span> document <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
jQuery.<span style="color: #660066;">getScript</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'&lt;?php echo $this-&gt;getSkinUrl('</span>videos<span style="color: #339933;">/</span>mediaplayer<span style="color: #339933;">/</span>swfobject.<span style="color: #660066;">js</span><span style="color: #3366CC;">'); ?&gt;'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> so <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> SWFObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/skin/frontend/[your-package]/[your-theme]/videos/mediaplayer/player.swf'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ply'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'470'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'320'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'9'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'#ffffff'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">addParam</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'allowfullscreen'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'true'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">addParam</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'allowscriptaccess'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'always'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">addParam</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'wmode'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'opaque'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">addVariable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'file'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'&lt;?php echo Mage::getBaseUrl(); ?&gt;/skin/frontend/[your-package]/[your-theme]/videos/&lt;?php echo $video; ?&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mediaspace'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;?</span>php <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;?</span>php echo $video<span style="color: #339933;">;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;?</span>php <span style="color: #009900;">&#125;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;?</span>php <span style="color: #009900;">&#125;</span> <span style="color: #339933;">?&gt;</span></pre></div></div>

<p>And save the file as /app/design/frontend/[your-package]/[your-theme]/template/catalog/product/view/video.phtml</p>
<p><strong>3b. catalog.xml</strong></p>
<p>Open up /app/design/frontend/[your-package]/[your-theme]/layout/catalog.xml and add this line:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;catalog/product_view&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product_video&quot;</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;product_video&quot;</span> <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;catalog/product/view/video.phtml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>as a child anywhere inside this node:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;catalog/product_view&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product.info&quot;</span> <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;catalog/product/view.phtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>&#8230; and save the file.</p>
<p><strong>3c. catalog/product/view.phtml</strong></p>
<p>Open up /app/design/frontend/[your-package]/[your-theme]/catalog/product/view.phtml and add this line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildHtml</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product_video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>wherever you want the video to appear on the page.  Save the file.</p>
<p><strong>4. Obtain and upload a copy of the free JWPlayer</strong></p>
<p>Download the player from: <a title="JWPlayer" href="http://www.longtailvideo.com/players/jw-flv-player/">http://www.longtailvideo.com/players/jw-flv-player/</a></p>
<p>After you download the ZIP file, extract and upload the files using an FTP client to: /skin/frontend/[your-package]/[your-theme]/videos/*</p>
<p>With the FTP client, rename the &#8220;mediaplayer-viral&#8221; folder to &#8220;mediaplayer&#8221;</p>
<p><strong>5. Add video to a product</strong></p>
<p>In the Magento Admin Panel, navigate to Catalog &gt; Manage Products and click on the product you&#8217;d like to add video to.  You should see a textarea labeled &#8220;Video&#8221;.</p>
<p><strong>5a. Use HTML embed code</strong></p>
<p>In the &#8220;Video&#8221; textarea, simply drop in the HTML code you&#8217;ve received (such as from YouTube) and click &#8220;Save&#8221; to save the product.</p>
<p><strong>5b. OR use an FLV file</strong></p>
<p>- Upload your FLV file to /skin/frontend/[your-package]/[your-theme]/videos/</p>
<p>- In the &#8220;Video&#8221; textarea, specify the filename of the FLV you&#8217;ve just uploaded.</p>
<p>Repeat Step 5 for all of the products you want to add video to.</p>
<p><strong>Congratulations, you&#8217;ve added video to your products.</strong></p>
<p>* This method is tested and working for Magento v 1.3.2.4</p>
<!-- Powered by Digg Digg plugin, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://www.redstage.com/magento/blog/2010/03/17/how-to-add-video-to-products-in-magento/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

