magento:在xml元素之前显示图像
我正在创建magento管理模块。基本上,我想在模块标题之前显示一个图像(图标) 我想做到这一点 我尝试了以下代码,但没有成功:(magento:在xml元素之前显示图像,xml,magento,Xml,Magento,我正在创建magento管理模块。基本上,我想在模块标题之前显示一个图像(图标) 我想做到这一点 我尝试了以下代码,但没有成功:( 标题 哪些输出是这样的 ----------编辑------ 我试图重写Adminhtml\u Block\u Page\u菜单,但没有成功 public function getMenuLevel($menu, $level = 0) { $html = '<ul ' . (!$level ? 'id="nav"' : '')
标题
哪些输出是这样的
----------编辑------
我试图重写Adminhtml\u Block\u Page\u菜单,但没有成功
public function getMenuLevel($menu, $level = 0)
{
$html = '<ul ' . (!$level ? 'id="nav"' : '') . '>' . PHP_EOL;
foreach ($menu as $index => $item) {
$html .= '<li ' . (!empty($item['children']) ? 'onmouseover="Element.addClassName(this,\'over\')" '
. 'onmouseout="Element.removeClassName(this,\'over\')"' : '') . ' class="'
. (!$level && !empty($item['active']) ? ' active' : '') . ' '
. (!empty($item['children']) ? ' parent' : '')
. (!empty($level) && !empty($item['last']) ? ' last' : '')
. ' level' . $level . '"> <a href="' . $item['url'] . '" '
. (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
. (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
. ($level === 0 && !empty($item['active']) ? 'active' : '') . '">'
////////////edits
. ($index == 'modulename' ? $item['label'] : '<span>'
. $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;
if (!empty($item['children'])) {
$html .= $this->getMenuLevel($item['children'], $level + 1);
}
$html .= '</li>' . PHP_EOL;
}
$html .= '</ul>' . PHP_EOL;
return $html;
}
公共函数getMenuLevel($menu,$level=0)
{
$html=';
foreach($index=>$item的菜单){
$html.='”.PHP_EOL;
如果(!空($item['children'])){
$html.=$this->getMenuLevel($item['children',$level+1);
}
$html.=''.PHP\u EOL;
}
$html.='
'.PHP\u EOL;
返回$html;
}
下面是config.xml菜单部分
<adminhtml>
<menu>
<company module="modulename" translate="title">
<title><![CDATA[<span class="module-icon">Company</span>]]></title>
<sort_order>71</sort_order>
<children>
<modulename translate="title" module="modulename">
<title>Theme Options</title>
<sort_order>0</sort_order>
<children>
<configuration>
<title>Configuration</title>
<sort_order>1</sort_order>
<action>adminhtml/system_config/edit/section/modulename</action>
</configuration>
</children>
</modulename>
</children>
</company>
</menu>
</adminhtml>
公司]]>
71
主题选项
0
配置
1.
adminhtml/system\u config/edit/section/modulename
管理菜单由Mage\u Adminhtml\u Block\u Page\u菜单生成,该菜单从标题中转义HTML(请参见getMenuLevel()
)。如果要在标题中添加图像,则需要重写此块以删除此行为。管理菜单由Mage\u Adminhtml\u block\u Page\u菜单生成,该菜单从标题中转义HTML(请参见getMenuLevel()
)。如果要在标题中添加图像,则需要重写此块以删除此行为。重写代码中的$index
变量来自何处?很抱歉,这是因为“foreach($index=>$item)和我现在在config.xml中使用Modulename]>,但运气不好:(是否Modulename
仍然被转义?您当前得到的结果是什么?当前我得到的是相同的Modulename
您是否测试了$index
的特定值是否正确?(您可以在问题中粘贴config.xml中的整个菜单定义吗?)您是否测试过菜单块是否真的被重写了?重写代码中的$index
变量来自何处?很抱歉,这是因为“foreach($menu as$index=>$item)”,我现在在config.xml中使用了Modulename]]>,但运气不好:(是否Modulename
仍然被转义?您当前得到的结果是什么?当前我得到的是相同的Modulename
您是否测试了$index
的特定值是否正确?(您可以在问题中粘贴config.xml中的整个菜单定义吗?)你测试过菜单块是否被重写了吗?
<adminhtml>
<menu>
<company module="modulename" translate="title">
<title><![CDATA[<span class="module-icon">Company</span>]]></title>
<sort_order>71</sort_order>
<children>
<modulename translate="title" module="modulename">
<title>Theme Options</title>
<sort_order>0</sort_order>
<children>
<configuration>
<title>Configuration</title>
<sort_order>1</sort_order>
<action>adminhtml/system_config/edit/section/modulename</action>
</configuration>
</children>
</modulename>
</children>
</company>
</menu>
</adminhtml>