Magento Category – Remove Breadcrumbs from Categories in Content Mode

breadcrumbscategory

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?

Best Answer

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()
    }
}
Related Topic