3

I want to remove breadcrumbs from category pages but only if the category was in content mode, means its 'Display Mode' was set to 'Static Block Only'.

How do I do that?

[UPDATE]
@Marius solution will get the job done but it will affect other themes as well (which is not my issue. I'll use his approach anyway). But is it possible to add a condition inside an action in catalog.xml file? I tried this with no luck:

<catalog_category_default translate="label">
    <label>Catalog Category (Non-Anchor)</label>
    <reference name="root">
        <action method="unsetChild"><name>breadcrumbs</name><call>isContentMode</call><if>1</if></action>
    </reference>
</catalog_category_default>

I copied the code in anchor categories as well. But breadcrumbs disappears in all category pages. I think I don't know exactly how I should use a condition inside <action> tag. Is it possible at all?

3 Answers 3

4

You can rewrite the category view block and remove the breadcrumbs block if the display mode is PAGE For this create a new module. ([Namespace]_[Module]). Here is what you need.
app/etc/modules/[Namespace]_[Module].xml - the declaration file

<?xml version="1.0"?>
<config>
    <modules>
        <[Namespace]_[Module]>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Catalog />
            </depends>
        </[Namespace]_[Module]>
    </modules>
</config>

app/code/local/[Namespace]/[Module]/etc/config.xml - the configuration file

<config>
    <modules>
        <[Namespace]_[Module]>
            <version>1.0.0</version>
        </[Namespace]_[Module]>
    </modules>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <category_view>[Namespace]_[Module]_Block_Category_View</category_view>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

app/code/local/[Namespace]/[Module]/Block/Category/View.php - your new block

<?php 
class [Namespace]_[Module]_Block_Category_View extends Mage_Catalog_Block_Category_View {
    protected function _prepareLayout() {
        if ($this->isContentMode()){ //if PAGE display then remove the breadcrumbs
            $this->getLayout()->getBlock('root')->unsetChild('breadcrumbs');
        }
        return parent::_prepareLayout()
    }
}

[EDIT] If you want to control this at a theme level you can try this.
Add in your layout file of the desired theme, this xml section:

<catalog_category_default>
    <reference name="category.products">
        <action method="setCanRemoveBreadcrumbs"><param>1</param></action>
    </reference>
</catalog_category_default>

Then the block described above becomes:

<?php 
class [Namespace]_[Module]_Block_Category_View extends Mage_Catalog_Block_Category_View {
    protected function _prepareLayout() {
        if ($this->getCanRemoveBreadcrumbs() && $this->isContentMode()){ //if PAGE display then remove the breadcrumbs
            $this->getLayout()->getBlock('root')->unsetChild('breadcrumbs');
        }
        return parent::_prepareLayout()
    }
}
2
  • Thanks. This works fine. But please take a look at my update. Do you have any comment? Commented Dec 17, 2013 at 8:49
  • @PedramBehroozi. See my update on the answer.
    – Marius
    Commented Dec 17, 2013 at 8:55
5

you have to add below xml tag in you local.xml files. It will remove breadcrumbs for category listing and layered navigation.

<catalog_category_default translate="label">
   <remove name="breadcrumbs"/>
</catalog_category_default>
<catalog_category_layered translate="label">
   <remove name="breadcrumbs"/>
</catalog_category_layered>
4
  • Thanks but this will remove breadcrumbs from all category pages. I just want breadcrumbs to remove from categories with 'Static Block Only' display mode. Commented Dec 17, 2013 at 7:00
  • for that you have to add condition if this is static block then don't display that breadcrumbs in phtml file.
    – Keyul Shah
    Commented Dec 17, 2013 at 7:10
  • How can I remove breadcrumbs within my catalog/category/view.phtml file? Commented Dec 17, 2013 at 7:15
  • no you have to change code in page/html/breadcrumbs.phtml file
    – Keyul Shah
    Commented Dec 17, 2013 at 7:18
2

You will need to edit the app/design/frontend/[package]/[template]/template/page/html/breadcrumbs.phtml for this. Please copy it from base/default to your own, current, template before editing.

In the breadcrumbs.phtml we'll have to check if there is a category and if so what kind of display mode it has.

if (
   Mage::registry('current_category') // do we have an active category
   && is_null(Mage::registry('current_product') // but not a product (otherwise this is product view)
   && Mage::registry('current_category')->getData('display_mode') == Mage_Catalog_Model_Category::DM_PAGE // and display mode is page
):

   [...] whatever you want to do when there is no breadcrumb [...]

else: // now we DO have a breadcrumb, so we'll display it

   [...] here goes the breadcrumb code [...]

endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.