Get a block type of a page Magento

899 views Asked by At

I would like to know how to find the block type of some page example : the home page.

I have a problem in my homepage, I want to display some block, in the xml I declared my block in <cms_index_index> (local.xml) but if I put it in the <reference name="head"> it appears, if <reference name="content"> or <reference name="content"> it does not work . It seems to me that the type of block is not good.

xml:

<cms_index_index>
        <reference name="root">
            <block type="core/template" name="seconnecter_test" template="customer/form/test-seconnecter.phtml"/>
        </reference>
</cms_index_index>

in the homepage 1column-full.phtml i called it like this:

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

There are 2 answers

10
Suman Singh On BEST ANSWER

You can use

<reference name="root">
    <block type="core/template" name="seconnecter_test" output="toHtml" template="customer/form/test-seconnecter.phtml"/>
</reference>
4
Shrikant On

When you give <reference name="content"> Their block type is core/text_list. this block type output their content automatically, you don't need to use getchildhtml().

In your local.xml

<?xml version="1.0"?>
 <layout version="0.1.0">
   <cms_index_index>
     <reference name="content">
       <block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/>
     </reference>
    </cms_index_index>
 </layout>

Place the template file at correct location, and the block will render at top of content.

Or try this go to cms->pages->homepage from admin panel. Add following in the layout update xml of design section

  <reference name="content">
       <block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/>
   </reference>

refresh the cache.