我目前正在使用扩展程序,我想向其中添加一些代码以覆盖通常显示在标题下的通知栏。根据我的检查,显示此内容的文件是......

/design/adminhtml/default/default/template/notification/toolbar.phtml

我尝试将以下代码添加到我的扩展的布局 xml 文件中,但它不起作用!

<reference name="notifications">
<action method="setTemplate">
<template>extension-folder/notification/toolbar.phtml</template>
</action>
</reference>

我检查了 adminnotification.xml 文件,我意识到它有以下代码:

<layout>
    <default>
        <reference name="notifications">
            <block type="adminhtml/notification_toolbar" name="notification_toolbar" as="notification_toolbar" acl="system/adminnotification/show_toolbar" template="notification/toolbar.phtml" />
        </reference>
        <reference name="notifications">
            <block type="adminhtml/notification_window" name="notification_window" as="notification_window" acl="system/adminnotification/show_toolbar" template="notification/window.phtml" />
        </reference>
    </default>
</layout>

所以我决定复制这一部分:

<reference name="notifications">
            <block type="adminhtml/notification_toolbar" name="notification_toolbar" as="notification_toolbar" acl="system/adminnotification/show_toolbar" template="notification/toolbar.phtml" />
        </reference>

并将其粘贴到我的扩展的 xml 文件中,并使用我修改后的模板位置修改模板部分。这有效,显示了我修改过的通知工具栏,但不知何故现在显示了它的 2 个实例,我不明白为什么!

有人可以帮忙吗?

有帮助吗?

解决方案

没关系,我知道我做错了什么!

我使用的参考名称不正确。而不是使用 notifications 我应该用过 notification_toolbar

如果您查看我为 adminnotification.xml 发布的代码,您会发现同一参考名称下有 2 个块。通过使用块名称,这会告诉 xml 我试图覆盖的特定块,这解决了问题!

许可以下: CC-BY-SA归因
scroll top