【问题标题】:custom template wasn't recognized in magento layout在 magento 布局中无法识别自定义模板
【发布时间】:2015-10-13 06:54:16
【问题描述】:

我创建了一个显示自定义前端页面的简单页面。我已经清除了我的缓存并检查了我所有的拼写错误,但是我无法弄清楚为什么我的模板没有呈现。我使用的是 magento 1.9.1.0 版。

这是我保存在 app/code/local/Rts/Prodselector/etc/config.xml 中的配置文件

<config>
    <frontend>
        <routers>
            <prodselector>
                <use>standard</use>
                <args>
                    <module>Rts_Prodselector</module>
                    <frontName>productselector</frontName>
                </args>
            </prodselector>
        </routers>
        <layout>
            <updates>
                <prodselector module="productselector_index_result">
                    <file>prodselector/result.xml</file>
                </prodselector>
            </updates>
        </layout>
    </frontend>
</config>

这是我保存在 app/code/local/controllers/IndexController.php 中的控制器

class Rts_Prodselector_IndexController extends Mage_Core_Controller_Front_Action {
    public function resultAction() {
        $this->loadLayout();
        $this->renderLayout();
    }
}

这是我保存在 app/design/frontend/base/default/layout/prodselector/result.xml 中的布局 xml

<layout>
    <productselector_index_result>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="core/template" name="productselector_index_result" template="prodselector/result.phtml" ></block>
        </reference>
    </productselector_index_result>
</layout>

我的模板保存在包含纯 html 的 app/design/frontend/base/default/template/prodselector/result.phtml 中。

我错过了什么吗?我是 magento 的新手,遇到了这个简单的问题。

====更新===

页面呈现三列布局。

谢谢!

【问题讨论】:

    标签: php xml magento


    【解决方案1】:

    在你的布局文件中,使用

    <prodselector_index_result>
    

    而不是

    <productselector_index_result>
    

    因为您已经在 config.xml 中以这种方式定义了它

    【讨论】:

      猜你喜欢
      • 2016-01-30
      • 2012-08-04
      • 2013-12-27
      • 2015-07-11
      • 2015-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多