0

In the image below you can see the structure of my module:

enter image description here

This is the content of Block/Product/View.php:

  <?php

    class NetGroup_Attributegrouping_Block_Product_View extends Mage_Core_Block_Template
    {
        function _construct(){

             $this->setTemplate('netgroup/attributegrouping/list.phtml');
        }
         function indexAction(){
               $this->setTemplate('netgroup/attributegrouping/list.phtml');
         }
    }

This is the content of etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Netgroup_Attributegrouping>
            <version>1.0.0</version>
        </Netgroup_Attributegrouping>
    </modules>

    <global>
        <blocks>
            <netgroup_attributegrouping>
                <class>Netgroup_Attributegrouping_Block</class>
            </netgroup_attributegrouping>
        </blocks>

        <helpers>
            <netgroup_attributegrouping>
                <class>Netgroup_Attributegrouping_Helper</class>
            </netgroup_attributegrouping>
        </helpers>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <netgroup_attributegrouping after="Mage_Adminhtml">Netgroup_Attributegrouping_Adminhtml</netgroup_attributegrouping>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    <adminhtml>
        <layout>
            <updates>
                <netgroup_attributegrouping>
                    <file>netgroup_attributegrouping.xml</file>
                </netgroup_attributegrouping>
            </updates>
        </layout>
    </adminhtml>

    <frontend>
        <layout>
            <updates>
                <netgroup_attributegrouping>
                    <file>netgroup_attributegrouping.xml</file>
                </netgroup_attributegrouping>
            </updates>
        </layout>
    </frontend>

</config>

In the design/frontend/netlogiq/default/layout/netgroup_attributegroping.xml content is:

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

    <catalog_product_view>

        <reference name="product.info">
            <block type="netgroup_attributegrouping/product_view" ></block>
        </reference>

    </catalog_product_view>

</layout>    

In the design/frontend/netlogiq/default/template/netgroup/attributegrouping/list.phtml content is:

<?php 

    echo 111111111111;

?>

AND finally in the app/design/frontend/netlgiq/default/template/catalog/product/view.phtml i have :

<div class="TEST"> TEST<br>
     <?php echo $this->getChildHtml('netgroup_attributegrouping'); ?>
</div>

I want to display my product in catalog/product/view.phtml. It does not display "1111111111" . I know there is a lot of mistakes, but what should i do , to make my module to work ? thx

3
    <reference name="product.info">
                <block type="netgroup_attributegrouping/product_view" name="netgroup_attributegrouping" as="netgroup_attributegrouping"></block>
            </reference>

then this will work `<?php echo $this->getChildHtml('netgroup_attributegrouping'); ?>`
|improve this answer|||||
  • ok it works, but could you explain me this part : name="netgroup_attributegrouping" as="netgroup_attributegrouping" ? – Attila Naghi Jul 30 '14 at 8:13
  • 1
    you are calling the getChildHtml and passing the parameter which is the name of the block ie netgroup_attributegrouping. but their is no block with this name netgroup_attributegrouping.so when you calling block with this name you are not getting this block.so we have to give a name to this block – Pradeep Sanku Jul 30 '14 at 8:20
  • any ideea why $_product is null if a put this code: $_product = $this->getProduct(); int list.phtml ? – Attila Naghi Jul 30 '14 at 9:36
1

You have not mention the block name and as. So change your layout file need to like this

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

    <catalog_product_view>

        <reference name="product.info">
            <block type="netgroup_attributegrouping/product_view" name="netgroup_attributegrouping" as="netgroup_attributegrouping"/>
        </reference>

    </catalog_product_view>

</layout>  

Then only you can get the file by this code

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

Note: You have to pass block as value not block name to the getChilHtml function parameter

|improve this answer|||||
  • it works, thx. question: what is name="product.info" ? where is defined? and im confused a little bit. I saw using this characters "/", "_","." in the name and i do not know the differences between them – Attila Naghi Jul 30 '14 at 8:16
  • @Chester check your catalog.xml file product.info is block name , so you have call that use that block. – MeenakshiSundaram R Jul 30 '14 at 8:17
  • @Chester "/", "_","." i can't understand what your asking – MeenakshiSundaram R Jul 30 '14 at 8:19
  • what does "." represents in the name ? – Attila Naghi Jul 30 '14 at 8:20
  • @Chester it just a character, you can use any thing in this. i.e., Each block name must be unique. – MeenakshiSundaram R Jul 30 '14 at 8:21

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.