Magento – Resolved – Custom Module Layout File Doesn’t Work – Magento 1.9

customlayoutmagento-1.9modulexml

For some reason the layout file of my module stopped working, please help!

This is the module's layout file at …

\app\design\frontend\rwd\default\layout\productcomment.xml

<layout>
   <catalog_product_view>
      <reference name="product.info">
          <block type="catalog/product_view_attributes" name="product.comment" as="additional" template="productcomment/productcomment.phtml">
                <action method="addToParentGroup"><group>detailed_info</group></action>
                <action method="setTitle" translate="value"><value>Product Comments</value></action>
          </block>
      </reference>
   </catalog_product_view>
</layout>

The same block in catalog.xml in the same directory works well (COMMENTED LINES):

<catalog_product_view translate="label">
    <label>Catalog Product View (Any)</label>
    <!-- Mage_Catalog -->
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
                <block type="core/text_list" name="product.info.media.after" as="after" />
            </block>
            <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
                <label>Alert Urls</label>
            </block>

            <action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action>

            <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
                <action method="setColumnCount"><columns>6</columns></action>
                <action method="setItemLimit"><type>upsell</type><limit>6</limit></action>
            </block>

            <block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />


            <!--<block type="catalog/product_view_attributes" name="product.comments" as="additional" template="productcomment/productcomment.phtml">
                <action method="setTitle" translate="value"><value>Product Comments</value></action>
            </block>-->

config.xml

<frontend>
    <layout>
        <updates>
            <productcomment module="Cpstest_ProductComment">
                <file>productcomment.xml</file>  
                <file>adminproductcomment.xml</file>                                                                           
            </productcomment>
        </updates>
    </layout>
</frontend>

Best Answer

The reason it didn't work was the config.xml file, where I had this:

    <config>
    <frontend>
      <layout>
        <updates>
            <productcomment module="Cpstest_ProductComment">
                <file>productcomment.xml</file>
                <file>adminproductcomment.xml</file>                                       
            </productcomment>
        </updates>
       </layout>
       .........

I removed the second file line and changed it to:

    <config>
    <frontend>
      <layout>
        <updates>
            <productcomment module="Cpstest_ProductComment">
                <file>productcomment.xml</file>                                     
            </productcomment>
        </updates>
       </layout>
       .........

and the module's layout file started to work properly. Hope this will help someone, I spent days on this issue.

Related Topic