Reputation: 1791
I'm just wondering if anyone has had any experience in formatting the breadcrumb in Magento?
I would like to replace the link that currently displays the text 'HOME' with an image.
I thought it would be a simple case of replacing some text with a picture but it seems the 'HOME' text/link is dynamically created as this is all that is in the breadcrumbs.phtml:
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>"><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Upvotes: 2
Views: 13658
Reputation: 7193
Edit your theme's breadcrumbs.phtml file:
/app/design/frontend/[YOUR_THEME]/default/template/page/html/breadcrumbs.phtml
If you want to replace the Home crumb with an image:
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['first']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>">
<img src="/your/image/path.png"/>
</a>
<?php elseif($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>"><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
If you want to remove the Home crumb entirely, which is what I needed:
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<?php if ($_crumbInfo['first']) continue ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
Upvotes: 0
Reputation: 141
No need to write any code for this,just using your translate file we can change "Home" in the breadcrumb.
For this :
goto your theme -> create locale directory-> create en_us directory -> create translate.csv .
In this just write below code
"Home","your choice".
Upvotes: 0
Reputation: 653
You can, in fact, hide that first "Home" from appear in your breadcrumbs without messing with CSS and keeping your HTML clean.
Just add the rule "!$_crumbInfo['first']" to your if conditions, just like:
<?php if ($crumbs && is_array($crumbs)): ?>
<?php foreach ($crumbs as $_crumbName => $_crumbInfo): ?>
<?php if ($_crumbInfo['link'] && !$_crumbInfo['first']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>"><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
<?php elseif ($_crumbInfo['last']): ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php elseif (!$_crumbInfo['first']): ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php else: ?>
<?php endif; ?>
<?php if (!$_crumbInfo['last'] && !$_crumbInfo['first']): ?>
»
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
Upvotes: 4
Reputation: 27119
Use CSS, this is a fight that isn't really worth it :) The 5 lines of CSS will take care of the issue much more easily than attempting to hack apart the breadcrumb renderers.
Upvotes: 1
Reputation: 2520
I think this is set in app/code/core/Mage/Cms/Block/Page.php. Look in the _prepareLayout() method (I am using magento 1.3, so this might be a little out of date).
I see you have a few options to update.
Upvotes: 2