From f2b081552514e3e76ae91ef20f9901447670b6c7 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 30 Aug 2017 19:18:40 +0200 Subject: [PATCH] Added addCrumbBefore() and removeCrumb() methods --- .../core/Mage/Page/Block/Html/Breadcrumbs.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php b/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php index a25dc6a2768..28764c982a3 100644 --- a/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php +++ b/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php @@ -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 *