I'm using Magento version 1.8.1.0.
I'm trying to create a new custom block module, which I'll use for creating a new home page.
- Namespace: Crusader
- Module: CLHomePage
- Block Type: crusaderhome
- Class: Qwerty (just for now while testing)
- Design Package: crusader
- Theme: default
This is what I have so far:
\app\etc\modules\Crusader_All.xml
<?xml version="1.0"?>
<config>
<modules>
<Crusader_CLHomePage>
<active>true</active>
<codePool>local</codePool>
</Crusader_CLHomePage>
</modules>
</config>
\app\code\local\Crusader\CLHomePage\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Crusader_CLHomePage>
<version>0.0.1</version>
</Crusader_CLHomePage>
</modules>
<global>
<blocks>
<crusaderhome>
<class>Crusader_CLHomePage_Block</class>
</crusaderhome>
</blocks>
</global>
</config>
\app\code\local\Crusader\CLHomePage\Block\Qwerty.php
<?php
class Crusader_CLHomePage_Block_Qwerty extends Mage_Core_Block_Template
{
// Methods (optional)
}
?>
\app\design\frontend\crusader\default\layout\local.xml
<?xml version="1.0" ?>
<layout>
<cms_index_index>
<reference name="content">
<block type="core/template" name="homepage" template="crusader/home.phtml">
<block type="crusaderhome/qwerty" name="homeads" as="homeads" template="crusader/homeads.phtml" />
</block>
</reference>
</cms_index_index>
</layout>
\app\design\frontend\crusader\default\template\crusader\home.phtml
<div id="home">
<p>Home Wrapper</p>
<?php echo $this->getChildHtml('homeads'); ?>
</div>
\app\design\frontend\crusader\default\template\crusader\homeads.phtml
<p>Adverts</p>
Now, with the above in place, my home page shows just "Home Wrapper", so the content of home.phtml is displayed, but not the content of homeads.phtml.
If I change the block type for homeads to core/template, it works, and I see both "Home Wrapper" and "Adverts". So I know the problem is something to do with the reference to my new block type (called crusaderhome).
What am I doing wrong here..?