php - Add custom block in Magento -


in magento 1.9 want add custom block homepage, nothing happens. have these files:

app/design/frontend/[mytheme]/default/layout/local.xml

<?xml version="1.0" encoding="utf-8"?> <layout>     <default>         <reference name="root">             <block type="core/text_list" name="customblock" as="customblock" translate="label">                 <label>custom block</label>             </block>         </reference>         <reference name="customblockreference">             <block type="core/template" name="customblock" template="customblock.phtml" />         </reference>     </default> </layout> 

in homepage.phtml

 <?php echo $this->getchildhtml('customblock') ?> 

in app/design/frontend/[mytheme]/default/template/customblock.phtml

<h1>test</h1> 

where doing wrong?

i assuming homepage.phtml root template using home page, please clarify if not case.

i think problem core/text_list block customblock getting rendered in root template homepage.phtml have not added block. core/text_list container renders child blocks added it.

it seems might trying add customblock.phtml new core/text_list, if case should this:

<reference name="root">     <block type="core/text_list" name="customblock" translate="label">         <label>custom block</label>         <block type="core/template" name="customblock-child" template="customblock.phtml"/>     </block> </reference> 

that add child template block directly core/text_list since defining both here in same file. however, if needed add new block core/text_list elsewhere, this:

<reference name="customblock">     <block type="core/template" name="customblock-child" template="customblock.phtml"/> </reference> 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -