我的Magento管理员视图中未加载我的布局 [英] My layout isn't loading in my Magento admin view

查看:74
本文介绍了我的Magento管理员视图中未加载我的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的控制器

<?php
class Desbest_Brands_Adminhtml_BrandController extends Mage_Adminhtml_Controller_action {
    public function indexAction() {
        //echo "showing 123 works!";
        $this->loadLayout(); $this->renderLayout();
    }

这是我的布局

<?xml version="1.0"?>
<layout version="1.0.0">
<brands_adminhtml_brand_index>
    <reference name="content">
        <block type="brands/adminhtml_brand" name="brand" />
        <block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>
    </reference>
</brands_adminhtml_brand_index>
</layout>

当我在管理员中显示视图时,甚至电子邮件订阅表单都没有加载.

Yet nothing loads up when I show the view in my admin, not even the email subscribe form.

推荐答案

如果正确调用了您的操作(显示回显123),则除了缓存问题外,您的句柄可能有问题.

If your action is called correctly (echo 123 shown), other than cache issue, there might be something's wrong with your handle.

在执行操作时,请尝试将此代码放在$this->loadLayout()之后:

In your action, try to put this code after $this->loadLayout() :

var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
die();

它将显示为该请求加载的所有句柄.

It will show all the handles loaded for that request.

该句柄是从fullActionName生成的,以简单的方式,我们可以说它是按以下方式生成的:

The handle is generated from fullActionName, in simple way, we can say that it is generated as:

route + controller + action

看看您的config.xml.

Take a look at your config.xml.

如果您的config.xml如:

If your config.xml like:

<admin>
    <routers>
        <brands>
            <use>admin</use>
            <args>
                <module>Desbest_Brands</module>
                <frontName>brands</frontName>
            </args>
        </brands>
    </routers>
</admin>

对于您的操作,它将生成句柄:<brands_adminhtml_brand_index>

For your action, it will generate handle: <brands_adminhtml_brand_index>

如果您的config.xml如:

If your config.xml like:

<admin>
    <routers>
        <brandsadmin>
            <use>admin</use>
            <args>
                <module>Desbest_Brands</module>
                <frontName>brands</frontName>
            </args>
        </brandsadmin>
    </routers>
</admin>

对于您的操作,它将生成句柄:<brandsadmin_adminhtml_brand_index>

For your action, it will generate handle: <brandsadmin_adminhtml_brand_index>

更新:

不要忘记在config.xml中定义您的管理布局,例如:

And don't forget to define your admin layout in your config.xml, eg:

<adminhtml>
    <layout>
        <updates>
            <brandsadmin>
                <file>yourlayoutname.xml</file>
            </brandsadmin>
        </updates>
    </layout>
</adminhtml>

将其放在app/design/adminhtml/default/[default/youradmintheme]/layout/yourlayoutname.xml

Put it under app/design/adminhtml/default/[default/youradmintheme]/layout/yourlayoutname.xml

这篇关于我的Magento管理员视图中未加载我的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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