I am converting an HTML template into Magento theme. Here I have to separate each blocks into custom static block files such as footermenu.phtml
, tweet.phtml
and copyright.phtml
to call like,
<?php echo $this->getChildHtml('footermenu'); ?>
<?php echo $this->getChildHtml('tweet'); ?>
<?php echo $this->getChildHtml('copyright'); ?>
After reading this blog tutorial, added a new block like the following but it is not appearing with my Magento 1.9.0.1
app/design/frontend/base/default/layout/local.xml
<?xml version="1.0"?>
<layout>
<reference name="root">
<block type="core/text_list" name="newreference" as="newreference" translate="label">
<label>New Reference</label>
</block>
</reference>
<reference name="newreference">
<block type="core/template" name="newreferenceblock" template="newreference.phtml" />
</reference>
</layout>
In app/design/frontend/base/default/template/page/2columns-right.phtml
<?php echo $this->getChildHtml('newreference') ?>
app/design/frontend/base/default/template/page/template/newreference.phtml
<h1 style="background-color:yellow">Hello New Reference!</h1>
Best Answer
If you want add this blocks to home page then you need to add this template under cms_index_index hadler:
if want to
show it at all pages then change handler cms_index_index to default
As your reference block name is footer then it need add code at footer.phtml
[Edit need] because getChildHtml() not exit for class render all chld phtml file of footer.phtml
More details at
http://www.magentocommerce.com/design_guide/articles/intro-to-layouts http://www.smashingmagazine.com/2012/11/30/introducing-magento-layout/
You have to put your child template files in
app/design/frontend/[base]/[default]/template/