Magento - How to replace 'Home' in the breadcrumb?

12,921

Solution 1

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.

Solution 2

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

Solution 3

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.

  1. Edit the file directly. (not my recommendation, but the fasted way)
  2. Override the class in your own module
  3. Create an entry your theme's translate.csv file. This is the way I like to update verbiage under normal situations, but it may not be your cup of tea. So in app/design/frontend/your_package/your_theme/locale/en_US/translate.csv you can put a new line that says "Home","" and then presto.
  4. Edit your css file instead of php/phtml files. If you are halfway experienced with css you can likely just set the text-indent to -2000em and set a background image.
Share:
12,921
Vince P
Author by

Vince P

Web designer since mid-90s... wow I'm old!

Updated on June 13, 2022

Comments

  • Vince P
    Vince P almost 2 years

    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>&gt;</span>
                <?php endif; ?>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
    <?php endif; ?>