Magento 1.7 – Add Child Block to Product Info Tabs Description Tab

layoutmagento-1.7product-viewtabstheme

I am using tabs for my product view page. In my local.xml I have the following:

<catalog_product_view>
    <reference name="product.info">
        <block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs"
                           template="catalog/product/view/tabs.phtml">
            <action method="addTab" translate="title" module="catalog">
                <alias>description</alias>
                <title>Description</title>
                <block>catalog/product_view_description</block>
                <template>catalog/product/view/description.phtml</template>
            </action>
            <action method="addTab" translate="title" module="catalog">
                <alias>videos</alias>
                <title>Videos</title>
                <block>catalog/product_view_attributes</block>
                <template>catalog/product/view/videos.phtml</template>
            </action>
        </block>
    </reference>
    <reference name="product.description">
        <block type="core/template"
               name="namespace.inline"
               as="namespace_inline"
               template="catalog/view/gallery/inline.phtml" />
    </reference>
</catalog_product_view>

In my catalog/product/view/description.phtml, I have the following:

<?php echo $this->getChildHtml('namespace_inline') ?>

But the child template does not render.

I tried switching to the default theme, and it works, but the default theme does not use tabs.

Is there something going on with the Mage_Catalog_Block_Product_View_Tabs block that does not allow it to have child blocks?

Best Answer

You are adding your block in a reference block. Since parent block of your custom block is a reference block, it is required that, this block should be defined before it get referenced in another place.

You said, when you try it in the base theme, it works. But in your custom theme its not working. So my strong believe is that, base theme holds block defines product.description inside it's catalog.xml layout file. But your custom theme is not using this name for that block, instead it may be using another name.

You need to find the block's name from catalog.xml file(in your custom theme) by referencing with it's type. (In base theme and custome theme, type of block would be same). Then use that name in your local.xml file.

Related Topic