Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
How to change breadcrumb according to our needs? 
 
proteam4
Jr. Member
 
Total Posts:  23
Joined:  2008-10-14
 

Hi,

I have a category “Books”

I have changed the footer to include a new link “Children books”. I have created a page for children books from magento admin panel “CMS->Manage Pages-> New Page”
When i am view this page its showing breadcrumb like “Home/ Children Books” where as i want it as “Home/ Books/ Children Books”

But also remeber that i have an “About Us” link in my website whose breadcrumb should be like “Home/ About Us” not “Home/ Books/ About Us”

Please tell me how can i customize the breadcrumb properly??

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lagad
Jr. Member
 
Total Posts:  3
Joined:  2007-12-29
 

Hello,

Is this possible, does someone knows how to do that ?

Many thanks for any help.

Regards,
Ed

 
Magento Community Magento Community
Magento Community
Magento Community
 
proteam4
Jr. Member
 
Total Posts:  23
Joined:  2008-10-14
 

Hi,

As you can see we didn’t get any replies from magento forum, so we have done this manually by adding the breadcrumb at our static pages. To do so we have first disabled the breadcrumb for CMS pages from “System -> Configuration -> Web -> under ‘Default Page Section’ put ‘No’ for ‘Show breadcrumbs for CMS pages’ “

This will disable the breadcrumb of all your static (CMS) pages, then add the following markup in starting of your static pages.

<h4 class="no-display">You’re currently on:</h4>
<ul class="breadcrumbs">
<li class="home">
<a href="{{store url=""}}" title="Go to Home Page">Home</a>
</li>
<li> / </li>
<li>
<a href="{{store url=""}}Books" title="Page Name">Your Previous Page Name</a>
</li>
<li> / </li>
<li>
<strong>Your Current Page Name</strong>
</li>
</ul>

We have solved it like this, see if it helps you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
proteam4
Jr. Member
 
Total Posts:  23
Joined:  2008-10-14
 

If you have some other way then please share it with us!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Juxecl
Member
 
Total Posts:  37
Joined:  2007-12-08
 

"Children Books” is a sub-category of “Books” isn’t it?

If I understand your problem properly you don’t need to create a cms page, you only need to create a new sub-category called “Children Books” under your “Books” category. Then you will get the “Home / Books / Children Books” breadcrumb navigation.

Or have I misunderstood your question?

 
Magento Community Magento Community
Magento Community
Magento Community
 
proteam4
Jr. Member
 
Total Posts:  23
Joined:  2008-10-14
 

Actually the children books page is a Static (CMS) page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Juxecl
Member
 
Total Posts:  37
Joined:  2007-12-08
 

ah, I see.

Well, static pages can only be one level down from the Home link so your solution is the only way, as far as I can tell. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chelramsey
Member
 
Total Posts:  33
Joined:  2008-12-01
 

I don’t know if this helps you or not, but going into app/design/default/default/template_name/templates/page/html/breadcrumb.phtml should be the file you need to edit. The path may be slightly off but hopefully that points you in the right direction.

=]

 
Magento Community Magento Community
Magento Community
Magento Community
 
rickygri
Jr. Member
 
Total Posts:  22
Joined:  2009-01-17
 

It would be super if Magento team would give some advice on this! Quite an old problem now!

 
Magento Community Magento Community
Magento Community
Magento Community
 
sakwoya
Jr. Member
 
Total Posts:  12
Joined:  2008-01-20
UK
 

Juxecl suggested:

If I understand your problem properly you don’t need to create a cms page, you only need to create a new sub-category called “Children Books” under your “Books” category. Then you will get the “Home / Books / Children Books” breadcrumb navigation.

If you do that and then make the Children’s Books category a ‘static block only’ one and then create your CMS as a static block (rather than a CMS page) then you can have your CMS displayed with a breadcrumb?

Graeme

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mmay
Jr. Member
 
Total Posts:  10
Joined:  2009-03-03
 

Well I too was struggling to edit the breadcrumbs of CMS page for ages and found the solution.

After long days, I got the idea.

If you want to edit the breadcrumbs of the CMS you have to go to app\code\core\Mage\Cms\Block and choose page.php and go to // show breadcrumbs at line 55 and play with it.

If you know PHP, you can play with breadcrumbs.

Keep in mind when you upgrade the Magento version to a newer version those files will be overwrite by Magento.

Good luck.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hansk87
Jr. Member
 
Total Posts:  1
Joined:  2010-09-27
 

Thanks Mmay, was also having the same problem.

Instead of the page title, I’m using the content heading now as a breadcrumb.
In /app/code/core/Mage/Cms/Block/Page.html on line 72, change

$breadcrumbs->addCrumb('cms_page', array('label'=>$page->getTitle(), 'title'=>$page->getTitle()));
into
$breadcrumbs->addCrumb('cms_page', array('label'=>$page->getContentHeading(), 'title'=>$page->getTitle()));
 
Magento Community Magento Community
Magento Community
Magento Community
 
kdorman
Jr. Member
 
Total Posts:  1
Joined:  2010-10-20
 
hans_k - 27 February 2011 11:21 AM

Thanks Mmay, was also having the same problem.

Instead of the page title, I’m using the content heading now as a breadcrumb.
In /app/code/core/Mage/Cms/Block/Page.html on line 72, change

$breadcrumbs->addCrumb('cms_page', array('label'=>$page->getTitle(), 'title'=>$page->getTitle()));
into
$breadcrumbs->addCrumb('cms_page', array('label'=>$page->getContentHeading(), 'title'=>$page->getTitle()));

I changed it into

$identifiers explode('/',$page->getIdentifier());
                
$current_identifier "";
                foreach(
$identifiers as $identifier{
                    
if($current_identifier != ""$current_identifier .= '/';
                    
$current_identifier .= $identifier;
                    if(
$current_identifier != $page->getIdentifier()) {
                        $title 
Mage::getModel('cms/page')->load($current_identifier'identifier')->getTitle();
                        
$breadcrumbs->addCrumb('cms_page_'.$identifier, array(
                                
'label'=>$title
                                
'title'=>$title,
                                
'link'=>Mage::getUrl($current_identifier)
                            )
                        );
                    
else {
                        $breadcrumbs
->addCrumb('cms_page_'.$identifier, array('label'=>$page->getTitle(), 'title'=>$page->getTitle()));
                    
}
                }
now with that you can create pages with as many level you want (needless to say the parents need to exist)
and it should react like it should
 
Magento Community Magento Community
Magento Community
Magento Community
 
viakondratiuk
Jr. Member
 
Total Posts:  25
Joined:  2010-05-18
 

Hi, as far as I know you can add static block for subcategory and default breadcrumbs functionality will be implemented.

 
Magento Community Magento Community
Magento Community
Magento Community
 
AndrewBessa
Jr. Member
 
Total Posts:  2
Joined:  2011-08-16
 

You can also add breadcrumbs by making an XML update:

<reference name="breadcrumbs">
    <
action method="addCrumb">
        <
crumbName>New Crumb</crumbName>
        <
crumbInfo>
            <
label>New Crumb</label>
            <
title>New Crumb</title>
            <
link>somewhere.html</link>
        </
crumbInfo>
    </
action>
</
reference>

The above code will only append a breadcrumb to the end… to put the breadcrumb were you want, you can use (notice the “after” clause):

<reference name="breadcrumbs">
    <
action method="addCrumb">
        <
crumbName>NewCrumb</crumbName>
        <
crumbInfo>
            <
label>NewCrumb</label>
            <
title>My New Crumb</title>
            <
link>somewhere.html</link>
        </
crumbInfo>
        <
after>home</after>
    </
action>
</
reference>

However, the above code will only work if you update the addCrumb method. The original addCrumb method doesn’t support the “after” claus.  The new method I wrote below will support <after></after> in the XML and place the breadcrumb accordingly. Just use the “crumbName” in the <after></after> XML data.  For example, the crumbName for the home page is “home”
app/code/code/Mage/Page/Block/Html/Breadcrumbs.php - line 59
Update the method to this:

function addCrumb($crumbName$crumbInfo$after false)
    
{
        
if($after !== false && is_array($this->_crumbs)) {
            $crumbs 
$this->_crumbs;
            
$this->_crumbs = array();
            foreach(
$crumbs as $_crumbName => $_crumb{
                $this
->_crumbs[$_crumbName] $_crumb;
                if(
$after == $_crumbName{
                    $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
                    if ((!isset(
$this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
                       $this
->_crumbs[$crumbName] $crumbInfo;
                    
}
                }
            }
        } 
else {
            $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
            if ((!isset(
$this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
               $this
->_crumbs[$crumbName] $crumbInfo;
            
}
        }
        
return $this;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
s.hafa
Jr. Member
 
Total Posts:  20
Joined:  2009-09-14
 

Hey Andrew,

thanks very much for that code!! I added 2 little lines of code because I have 2 storeviews and only one breadcrumb. That’s why I need the baseUrl in the link. I did not find out how to use a helper in my xml configuration. I decided to just always add the base url when I use the after param.

So here is what I changed:

function addCrumb($crumbName$crumbInfo$after false)
    
{
        
if($after !== false && is_array($this->_crumbs)) {
            $crumbs 
$this->_crumbs;
            
$this->_crumbs = array();
            foreach(
$crumbs as $_crumbName => $_crumb{
                $this
->_crumbs[$_crumbName] $_crumb;
                if(
$after == $_crumbName{
                    $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
                    if(
$crumbInfo['link'!= ''{
                        $crumbInfo[
'link'Mage::getBaseUrl().$crumbInfo['link'];
                    
}
                    
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {                      
                        $this
->_crumbs[$crumbName] $crumbInfo;
                    
}
                }
            }
        } 
else {
            $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
            if ((!isset(
$this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) 
               $this
->_crumbs[$crumbName] $crumbInfo;
            
}
        }
        
return $this;
    
}

Merry Christmas!!

Sebastian

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2