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

asked Jul 30, 2014 at 8:03
0

2 Answers 2

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'); ?>`
answered Jul 30, 2014 at 8:08
3
  • ok it works, but could you explain me this part : name="netgroup_attributegrouping" as="netgroup_attributegrouping" ? Commented Jul 30, 2014 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 Commented Jul 30, 2014 at 8:20
  • any ideea why $_product is null if a put this code: $_product = $this->getProduct(); int list.phtml ? Commented Jul 30, 2014 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

answered Jul 30, 2014 at 8:11
5
  • 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 Commented Jul 30, 2014 at 8:16
  • @Chester check your catalog.xml file product.info is block name , so you have call that use that block. Commented Jul 30, 2014 at 8:17
  • @Chester "/", "_","." i can't understand what your asking Commented Jul 30, 2014 at 8:19
  • what does "." represents in the name ? Commented Jul 30, 2014 at 8:20
  • @Chester it just a character, you can use any thing in this. i.e., Each block name must be unique. Commented Jul 30, 2014 at 8:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.