【发布时间】:2014-05-22 10:16:23
【问题描述】:
我使用的是 Magento 版本 1.8.1.0。
我正在尝试创建一个新的自定义块模块,我将使用它来创建一个新的主页。
- 命名空间:十字军
- 模块:CLHomePage
- 方块类型:十字军之家
- 类:Qwerty(仅在测试中)
- 设计包:十字军
- 主题:默认
这是我目前所拥有的:
\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>
现在,有了以上内容,我的主页只显示“Home Wrapper”,因此显示home.phtml 的内容,而不显示homeads.phtml 的内容。
如果我将homeads 的块类型更改为core/template,它会起作用,并且我会看到“Home Wrapper”和“Adverts”。所以我知道问题与对我的新块类型(称为 crusaderhome)的引用有关。
我在这里做错了什么..?
【问题讨论】: