Skip to content

Commit

Permalink
Added addCrumbBefore() and removeCrumb() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored and colinmollenhour committed Jan 3, 2018
1 parent 1645688 commit f2b0815
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/code/core/Mage/Page/Block/Html/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ public function addCrumb($crumbName, $crumbInfo, $after = false)
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 f2b0815

Please sign in to comment.