0

I'm trying to create a template file for a youtube video and some javascript. It should be added to the catalog/product/view/description block with the following PHP

 echo $this->getChildHtml('youtube')

This is the XML in my local.xml file that I'm using to try and get this to happen

<default>
    <catalog_product_view>
        <reference name="content">
            <reference name="product.info">
                <reference name="product.description">
                    <block type="core/template" name="product.youtube" as="product_youtube" template="catalog/product/view/youtube.phtml" />
                </reference>
            </reference>
        </reference>
    </catalog_product_view>
</default>

The template as of now just has a simple 'hello' but I don't get any output on my product page. What am I doing wrong?

3
  • remove <default> and </default> Commented May 9, 2016 at 10:29
  • That actually did the trick, thankyou. Can you post it as an answer? Commented May 9, 2016 at 10:34
  • Sure. Check detailed answer Commented May 9, 2016 at 10:36

2 Answers 2

2

local.xml should look like

<?xml version="1.0"?>
<layout version="0.1.0">
...

    <catalog_product_view>
        <reference name="content">
            <reference name="product.info">
                <reference name="product.description">
                    <block type="core/template" name="product.youtube" as="product_youtube" template="catalog/product/view/youtube.phtml" />
                </reference>
            </reference>
        </reference>
    </catalog_product_view>

...
</layout>

<default> and <catalog_product_view> are different handles.

So you should remove <default>

Also use $this->getChildHtml('product_youtube') to echo block

1

Small mistake echo $this->getChildHtml('youtube') should be echo $this->getChildHtml('product_youtube')

As your block alias name is product_youtube (as="product_youtube") and trying to call echo $this->getChildHtml('youtube')

Also as Anil mention

remove <default> and </default>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.