Reputation: 5781
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.
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..?
Upvotes: 3
Views: 13270
Reputation: 5781
I found the answer after posting on the Magento stack exchange site:
https://magento.stackexchange.com/questions/18098/magento-new-custom-block-module
It was the Magento compiler, once I disabled the compiler it seems to work.
Admin > System > Tools > Compilation
Upvotes: 2
Reputation: 1720
First of all
change \app\etc\modules\Crusader_All.xml
to
\app\etc\modules\Crusader_CLHomePage.xml
use cLHomePage
(check the naming convention. You should use lowercase like Clhomepage
) rather crusaderhome
in block type.
in
<block type="crusaderhome/qwerty" name="homeads" as="homeads" template="crusader/homeads.phtml" />
Upvotes: 2