Removing Home from Breadcrumbs
I need to remove the Home link from the Breadcrumbs (i.e., from Home > Catalog > Product to simply Catalog > Product).
I looked at how to override the _prepareLayout() method of MagentoCatalogBlockBreadcrumbs (Change Breadcrumbs Home link's URL 2.1), and that works fine.
However, when I remove the addCrumb method that adds the Home breadcrumb, it removes the Home breadcrumb from the beginning of the list as expected, but the Home breadcrumb gets added again at the end of the list (i.e., Catalog > Product > Home)!
Is there another file appending the Home breadcrumb? How do I remove the Home link completely?
magento2
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I need to remove the Home link from the Breadcrumbs (i.e., from Home > Catalog > Product to simply Catalog > Product).
I looked at how to override the _prepareLayout() method of MagentoCatalogBlockBreadcrumbs (Change Breadcrumbs Home link's URL 2.1), and that works fine.
However, when I remove the addCrumb method that adds the Home breadcrumb, it removes the Home breadcrumb from the beginning of the list as expected, but the Home breadcrumb gets added again at the end of the list (i.e., Catalog > Product > Home)!
Is there another file appending the Home breadcrumb? How do I remove the Home link completely?
magento2
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28
add a comment |
I need to remove the Home link from the Breadcrumbs (i.e., from Home > Catalog > Product to simply Catalog > Product).
I looked at how to override the _prepareLayout() method of MagentoCatalogBlockBreadcrumbs (Change Breadcrumbs Home link's URL 2.1), and that works fine.
However, when I remove the addCrumb method that adds the Home breadcrumb, it removes the Home breadcrumb from the beginning of the list as expected, but the Home breadcrumb gets added again at the end of the list (i.e., Catalog > Product > Home)!
Is there another file appending the Home breadcrumb? How do I remove the Home link completely?
magento2
I need to remove the Home link from the Breadcrumbs (i.e., from Home > Catalog > Product to simply Catalog > Product).
I looked at how to override the _prepareLayout() method of MagentoCatalogBlockBreadcrumbs (Change Breadcrumbs Home link's URL 2.1), and that works fine.
However, when I remove the addCrumb method that adds the Home breadcrumb, it removes the Home breadcrumb from the beginning of the list as expected, but the Home breadcrumb gets added again at the end of the list (i.e., Catalog > Product > Home)!
Is there another file appending the Home breadcrumb? How do I remove the Home link completely?
magento2
magento2
asked Apr 17 '17 at 0:51
user3591139user3591139
62
62
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 days ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28
add a comment |
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28
add a comment |
2 Answers
2
active
oldest
votes
As you have follow Change Breadcrumbs Home link's URL 2.1
So, first you need remove
$breadcrumbsBlock->addCrumb(
'home',
[
'label' => __('Home'),
'title' => __('Go to Home Page'),
'link' => $this->_storeManager->getStore()->getBaseUrl()
]
);
from rewrite class
add return MagentoFrameworkViewElementTemplate::_prepareLayout();
Class:
<?php
namespace [Vendorname][ModulenamePlugin;
class Breadcrumbs extends MagentoCatalogBlockBreadcrumbs
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCatalogHelperData $catalogData,
array $data = array()) {
parent::__construct($context, $catalogData, $data);
}
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$title = ;
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return MagentoFrameworkViewElementTemplate::_prepareLayout();
}
}
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
add a comment |
I would edit your breadcrumbs.phtml to include an if statement within the foreach loop to check whether the breadcrumb label is not equal to home to then loop through the breadcrumbs.
Something like:
<?php foreach ($crumbs as $crumbName => $crumbInfo) :
if ($block->escapeHtml($crumbInfo['label']) != "Home") {
//li for breadcrumb here
}
endforeach;
?>
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f170374%2fremoving-home-from-breadcrumbs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As you have follow Change Breadcrumbs Home link's URL 2.1
So, first you need remove
$breadcrumbsBlock->addCrumb(
'home',
[
'label' => __('Home'),
'title' => __('Go to Home Page'),
'link' => $this->_storeManager->getStore()->getBaseUrl()
]
);
from rewrite class
add return MagentoFrameworkViewElementTemplate::_prepareLayout();
Class:
<?php
namespace [Vendorname][ModulenamePlugin;
class Breadcrumbs extends MagentoCatalogBlockBreadcrumbs
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCatalogHelperData $catalogData,
array $data = array()) {
parent::__construct($context, $catalogData, $data);
}
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$title = ;
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return MagentoFrameworkViewElementTemplate::_prepareLayout();
}
}
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
add a comment |
As you have follow Change Breadcrumbs Home link's URL 2.1
So, first you need remove
$breadcrumbsBlock->addCrumb(
'home',
[
'label' => __('Home'),
'title' => __('Go to Home Page'),
'link' => $this->_storeManager->getStore()->getBaseUrl()
]
);
from rewrite class
add return MagentoFrameworkViewElementTemplate::_prepareLayout();
Class:
<?php
namespace [Vendorname][ModulenamePlugin;
class Breadcrumbs extends MagentoCatalogBlockBreadcrumbs
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCatalogHelperData $catalogData,
array $data = array()) {
parent::__construct($context, $catalogData, $data);
}
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$title = ;
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return MagentoFrameworkViewElementTemplate::_prepareLayout();
}
}
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
add a comment |
As you have follow Change Breadcrumbs Home link's URL 2.1
So, first you need remove
$breadcrumbsBlock->addCrumb(
'home',
[
'label' => __('Home'),
'title' => __('Go to Home Page'),
'link' => $this->_storeManager->getStore()->getBaseUrl()
]
);
from rewrite class
add return MagentoFrameworkViewElementTemplate::_prepareLayout();
Class:
<?php
namespace [Vendorname][ModulenamePlugin;
class Breadcrumbs extends MagentoCatalogBlockBreadcrumbs
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCatalogHelperData $catalogData,
array $data = array()) {
parent::__construct($context, $catalogData, $data);
}
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$title = ;
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return MagentoFrameworkViewElementTemplate::_prepareLayout();
}
}
As you have follow Change Breadcrumbs Home link's URL 2.1
So, first you need remove
$breadcrumbsBlock->addCrumb(
'home',
[
'label' => __('Home'),
'title' => __('Go to Home Page'),
'link' => $this->_storeManager->getStore()->getBaseUrl()
]
);
from rewrite class
add return MagentoFrameworkViewElementTemplate::_prepareLayout();
Class:
<?php
namespace [Vendorname][ModulenamePlugin;
class Breadcrumbs extends MagentoCatalogBlockBreadcrumbs
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoCatalogHelperData $catalogData,
array $data = array()) {
parent::__construct($context, $catalogData, $data);
}
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$title = ;
$path = $this->_catalogData->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title = $breadcrumb['label'];
}
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
}
return MagentoFrameworkViewElementTemplate::_prepareLayout();
}
}
edited Apr 17 '17 at 5:57
answered Apr 17 '17 at 4:38
Amit Bera♦Amit Bera
57.3k1474171
57.3k1474171
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
add a comment |
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
Hi, yes, I mean I've removed that block. However, Home still shows up, but at the end of the list instead. The effect of removing that block is changing Home > Catalog > Product into Catalog > Product > Home. Which is not what I want. Any ideas?
– user3591139
Apr 17 '17 at 5:10
add a comment |
I would edit your breadcrumbs.phtml to include an if statement within the foreach loop to check whether the breadcrumb label is not equal to home to then loop through the breadcrumbs.
Something like:
<?php foreach ($crumbs as $crumbName => $crumbInfo) :
if ($block->escapeHtml($crumbInfo['label']) != "Home") {
//li for breadcrumb here
}
endforeach;
?>
add a comment |
I would edit your breadcrumbs.phtml to include an if statement within the foreach loop to check whether the breadcrumb label is not equal to home to then loop through the breadcrumbs.
Something like:
<?php foreach ($crumbs as $crumbName => $crumbInfo) :
if ($block->escapeHtml($crumbInfo['label']) != "Home") {
//li for breadcrumb here
}
endforeach;
?>
add a comment |
I would edit your breadcrumbs.phtml to include an if statement within the foreach loop to check whether the breadcrumb label is not equal to home to then loop through the breadcrumbs.
Something like:
<?php foreach ($crumbs as $crumbName => $crumbInfo) :
if ($block->escapeHtml($crumbInfo['label']) != "Home") {
//li for breadcrumb here
}
endforeach;
?>
I would edit your breadcrumbs.phtml to include an if statement within the foreach loop to check whether the breadcrumb label is not equal to home to then loop through the breadcrumbs.
Something like:
<?php foreach ($crumbs as $crumbName => $crumbInfo) :
if ($block->escapeHtml($crumbInfo['label']) != "Home") {
//li for breadcrumb here
}
endforeach;
?>
answered Jun 15 '17 at 11:56
heady12heady12
357422
357422
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f170374%2fremoving-home-from-breadcrumbs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please copy your code, not screenshot.
– syahidah humairoh
Apr 17 '17 at 4:28