且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我的Magento管理员视图中未加载我的布局

更新时间:2023-11-29 23:25:16

如果正确调用了您的操作(显示回显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