Skip to content

Commit

Permalink
[bug-OpenMage#336] Mage_Page_Block_Html_Breadcrumbs::addCrumb() isn't…
Browse files Browse the repository at this point in the history
… fully implemented

The third parameter `$after` is ignored/has no affect...

This should work correctly now...

 $block->addCrumb('my_crumb', array(
     'label'    => label,
     'title'    => title,
 ), 'home');
  • Loading branch information
sreichel authored and edannenberg committed Feb 28, 2018
1 parent abbe510 commit 0006bd3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion app/code/core/Mage/Page/Block/Html/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,40 @@ public function addCrumb($crumbName, $crumbInfo, $after = false)
{
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
if ($after && isset($this->_crumbs[$after])) {
$offset = array_search($after, array_keys($this->_crumbs)) + 1;
$this->_crumbs = array_slice($this->_crumbs, 0, $offset, true) + array($crumbName => $crumbInfo) + array_slice($this->_crumbs, $offset, null, true);
} else {
$this->_crumbs[$crumbName] = $crumbInfo;
}
}
return $this;
}

public function addCrumbBefore($crumbName, $crumbInfo, $before = false)
{
if ($before && isset($this->_crumbs[$before])) {
$keys = array_keys($this->_crumbs);
$offset = array_search($before, $keys);
# add before first
if (!$offset) {
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
$this->_crumbs = array($crumbName => $crumbInfo) + $this->_crumbs;
} else {
$this->addCrumb($crumbName, $crumbInfo, $keys[$offset-1]);
}
} else {
$this->addCrumb($crumbName, $crumbInfo);
}
}

public function removeCrumb($crumbName)
{
if (isset($this->_crumbs[$crumbName])) {
unset($this->_crumbs[$crumbName]);
}
}

/**
* Get cache key informative items
*
Expand Down

0 comments on commit 0006bd3

Please sign in to comment.