Magento新的自定义块模块 [英] Magento new custom block module

查看:92
本文介绍了Magento新的自定义块模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Magento版本 1.8.1.0.

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.

  • 命名空间:十字军
  • 模块:CLHomePage
  • 块类型:crusaderhome
  • 类:Qwerty(仅在测试时才适用)
  • 设计包:十字军
  • 主题:默认

这是我到目前为止所拥有的:

This is what I have so far:

\ app \ etc \ modules \ Crusader_All.xml

\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

\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

\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

\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

\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

\app\design\frontend\crusader\default\template\crusader\homeads.phtml

<p>Adverts</p>

现在,使用上述内容,我的主页上仅显示"Home Wrapper",因此显示的是home.phtml的内容,而不显示的是homeads.phtml的内容.

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.

如果将homeads的块类型更改为core/template,则它可以工作,并且同时看到"Home Wrapper"和"Adverts".所以我知道问题出在我的新块类型(称为crusaderhome)的引用上.

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..?

推荐答案

我在Magento堆栈交换站点上发布后找到了答案:

I found the answer after posting on the Magento stack exchange site:

https://magento.stackexchange.com/questions/18098/magento-new -custom-block-module

这是Magento编译器,一旦我禁用了该编译器,它似乎就可以工作了.

It was the Magento compiler, once I disabled the compiler it seems to work.

管理员>系统>工具>编译

Admin > System > Tools > Compilation

这篇关于Magento新的自定义块模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆