0

I have created a module and when I put its block in magento catalog.xml it shows up. But when I place the code in my module's productcomments.xml layout file, it doesn't show anything. Can anyone help me with this? Thanks in advance!

Here is the config.xml

<config>
    <modules>
        <Cpstest_ProductComments>
            <version>0.1.0</version>
        </Cpstest_ProductComments>
    </modules>
    <frontend>     
        <layout>
            <updates>
                <productcomments>
                    <file>productcomments.xml</file>
                </productcomments>
            </updates>
        </layout>
        <routers>
            <productcomments>
                <use>standard</use>
                <args>
                    <module>Cpstest_ProductComments</module>
                    <frontName>productcomments</frontName>
                </args>
            </productcomments>
        </routers>
    </frontend>
    <global>
        <resources>
         <productcomments_setup>
                <setup>
                    <module>Cpstest_ProductComments</module>
                    <class>Mage_Eav_Model_Entity_Setup</class>
                   <class>Cpstest_ProductComments_Model_Resource_Mysql4_Setup</class>
                    <class>Mage_Catalog_Model_Resource_Setup</class> <!---->
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </productcomments_setup>
            <productcomments_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </productcomments_write>
            <productcomments_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </productcomments_read>
        </resources> 
        <helpers>
            <productcomments>
                <class>Cpstest_ProductComments_Helper</class>                                                             
            </productcomments>
        </helpers>
    </global>  
</config>

This is productcomments.xml

<?xml version="1.0"?>
    <catalog_product_view>
       <reference name="content">
            <reference name="product.info">    
                 <block type="catalog/product_view_attributes" name="product.comments" as="additional" template="productcomments/productcomments.phtml">
                    <action method="setTitle" translate="value"><value>Product Comments</value></action>
                </block>                
            </reference>
       </reference>
    </catalog_product_view>
</layout>

And the working code in catalog.xml is:

<catalog_product_view translate="label">        
     <reference name="content">
     <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
     <block type="catalog/product_view_attributes" name="product.comments" as="additional" template="productcomments/productcomments.phtml">
     <action method="setTitle" translate="value"><value>Product Comments</value>     </action>
 </block>
.....
1

Try this code for your productcomments.xml

<?xml version="1.0"?>
<layout>
    <catalog_product_view>
        <reference name="product.info">    
             <block type="catalog/product_view_attributes" name="product.comments" as="comments" template="productcomments/productcomments.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>
  • Guys thanks so much for your help. Looks like I was missing the <layout>.. Wow I spend 2 days for this.. Really really appreciate the help from both of you!! – bestwebdevs Mar 7 '17 at 21:49
1
   <reference name="content">
        <reference name="product.info">    

I doubt above syntax will not work, And also you miss start layout

try below code , and your productcomments.xml would be

<?xml version="1.0"?>
<layout>
    <catalog_product_view>
        <reference name="product.info">    
             <block type="catalog/product_view_attributes" name="product.comments" as="additional" template="productcomments/productcomments.phtml">
                <action method="setTitle" translate="value"><value>Product Comments</value></action>
            </block>                
        </reference>
    </catalog_product_view>
</layout>
0

Inside your config.xml try adding a module tag to the layout update.

Here's how I have it in mind:

<layout>
    <updates>
        <productcomments module="Cpstest_ProductComments">
            <file>productcomments.xml</file>
        </productcomments>
    </updates>
</layout>
  • thanks for your answer. I tried, but that didn't work. – bestwebdevs Mar 7 '17 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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