Removing Home from Breadcrumbs












1














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?



enter image description here










share|improve this question














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
















1














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?



enter image description here










share|improve this question














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














1












1








1


1





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?



enter image description here










share|improve this question













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?



enter image description here







magento2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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










2 Answers
2






active

oldest

votes


















0














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();
}


}





share|improve this answer























  • 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





















-1














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;
?>





share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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();
    }


    }





    share|improve this answer























    • 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


















    0














    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();
    }


    }





    share|improve this answer























    • 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
















    0












    0








    0






    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();
    }


    }





    share|improve this answer














    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();
    }


    }






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 17 '17 at 5:57

























    answered Apr 17 '17 at 4:38









    Amit BeraAmit 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




















    • 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















    -1














    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;
    ?>





    share|improve this answer


























      -1














      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;
      ?>





      share|improve this answer
























        -1












        -1








        -1






        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;
        ?>





        share|improve this answer












        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;
        ?>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 15 '17 at 11:56









        heady12heady12

        357422




        357422






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            An IMO inspired problem

            Management

            Has there ever been an instance of an active nuclear power plant within or near a war zone?