Skip to content

Commit bc33791

Browse files
authored
Added ability to add target attribute for adminhtml menu items (#1985)
* Adminhtml menu cleanup, added ability to add target for menu items * Added ability to add target for menu items
1 parent d055554 commit bc33791

File tree

2 files changed

+11
-6
lines changed
  • app
    • code/core/Mage/Adminhtml/Block/Page
    • design/adminhtml/default/default/template/page

2 files changed

+11
-6
lines changed

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public function getCacheKeyInfo()
9595
*/
9696
public function getMenuArray()
9797
{
98-
return $this->_buildMenuArray();
98+
$parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
99+
100+
return $this->_buildMenuArray($parent);
99101
}
100102

101103
/**
@@ -127,12 +129,8 @@ protected function _getHelperValue(Varien_Simplexml_Element $child)
127129
* @param int $level
128130
* @return array
129131
*/
130-
protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path='', $level=0)
132+
protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path='', $level=0)
131133
{
132-
if (is_null($parent)) {
133-
$parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
134-
}
135-
136134
$parentArr = array();
137135
$sortOrder = 0;
138136
foreach ($parent->children() as $childName => $child) {
@@ -167,6 +165,10 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path=
167165

168166
$menuArr['level'] = $level;
169167

168+
if ($child->target) {
169+
$menuArr['target'] = $child->target;
170+
}
171+
170172
if ($child->children) {
171173
$menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1);
172174
}
@@ -294,6 +296,7 @@ public function getMenuLevel($menu, $level = 0)
294296
. (!empty($level) && !empty($item['last']) ? ' last' : '')
295297
. ' level' . $level . '"> <a href="' . $item['url'] . '" '
296298
. (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
299+
. (!empty($item['target']) ? 'target="' . $item['target'] . '"' : '') . ' '
297300
. (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'
298301
. ($level === 0 && !empty($item['active']) ? 'active' : '') . '"><span>'
299302
. $this->escapeHtml($item['label']) . '</span></a>' . PHP_EOL;

app/design/adminhtml/default/default/template/page/menu.phtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
2424
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
2525
*/
26+
27+
/** @var $this Mage_Adminhtml_Block_Page_Menu */
2628
?>
2729

2830
<div class="nav-bar">

0 commit comments

Comments
 (0)