创建自定义Magento模块。没有检测模板

时间:2010-08-20 17:53:57

标签: php zend-framework magento

我正在创建一个带有新网址的自定义模块。截至目前。如果我将一个echo放入我的Indexcontroller类并转到mydomain.com/index.php/advancedcatalog,它会检测到回声但是它没有检测到我的视图。这是我的结构

/Advancedcatalog/Block/Advancedcatalog.php

Advancedcatalog.php

<?php
class Webwow_Advancedcatalog_Block_Advancedcatalog extends Mage_Core_Block_Template
{
    public function _prepareLayout()
    {
        return parent::_prepareLayout();
    }

    public function getHelloworld()
    {
        return 'Hello world';
    }
}

/Advancedcatalog/controllers/IndexController.php

IndexController.php

<?php
class Webwow_Advancedcatalog_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

/Advancedcatalog/Model/Advancedcatalog.php

Advancedcatalog.php

<?php 
class Webwow_Advancedcatalog_Model_Advancedcatalog extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('advancedcatalog/advancedcatalog');
    }
}

/Advancedcatalog/etc/config.xml

<?xml version="1.0" ?>
    <config>
    <modules>
        <Webwow_Advancedcatalog>
            <version>0.1.0</version>
        </Webwow_Advancedcatalog>
    </modules>
     <frontend>
        <routers>
            <advancedcatalog>
                <use>standard</use>
                <args>
                    <module>Webwow_Advancedcatalog</module>
                    <frontName>advancedcatalog</frontName>
                </args>
            </advancedcatalog>
        </routers>
        <layout>
            <updates>
                <advancedcatalog>
                    <file>advancedcatalog.xml</file>
                </advancedcatalog>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <advancedcatalog>
                <class>Webwow_Advancedcatalog_Block</class>
            </advancedcatalog>
        </blocks>
    </global>
</config>

这是我的布局

/layout/advancedcatalog.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <advancedcatalog_index_index>
        <reference name="content">
            <block type="advancedcatalog/advancedcatalog" name="advancedcatalog"
            template="advancedcatalog/helloworld.phtml" />
        </reference>
    </advancedcatalog_index_index>
</layout>   

/templates/advancedcatalog/helloworld.phtml

<h2><?php echo $this->getHelloworld(); ?></h2>
TESTING

1 个答案:

答案 0 :(得分:2)

解决了这个问题。我意外地将布局文件放在了错误的主题