Search code examples
magentoiconshtml5boilerplatefont-awesome-4

How to add font awesome icons in top links of Magento


I am using boilerplate template for Magento and there is font awesome already included with this template. I create a bootstrap button for my car in top links by adding a class="btn btn-primary" in Links.php and now I am facing an issue when trying to add the cart icon from font awesome...

I would like to add this code in front of "My Cart (2 items)" top links: My cart

I have tried few things without success...

thanks for any help

edit: this is what my top.links.phtml look like and I can't figure out how to add your code:

<?php if($toplinks && is_array($toplinks)): ?>
<ul class="links">
<?php echo $this->getChildHtml() ?>
<?php foreach($toplinks as $_toplink): ?>
<li<?php if($_toplink['first']||$_toplink['last']): ?> class="<?php if($_toplink['first']): ?>first<?php endif; ?><?php if($_toplink['last']): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_toplink['liParams'] ?>><?php echo $_toplink['beforeText'] ?><a <?php echo $_toplink['aParams'] ?>><?php echo $_toplink['innerText'] ?></a><?php echo $_toplink['afterText'] ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

Solution

  • Foolow this link:

    http://www.ibeccreative.com/blog/151/Magento-Tutorial-How-to-Customize-the-Top-Links-Block/

    and for some links as wishlist:

    app/design/frontend/[[YOURTHEME]]/default/layout/wishlist.xml

    Change:

       <reference name="top.links">
                <block type="wishlist/links" name="wishlist_link" />
                <action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
            </reference>
    

    To:

    <reference name="top.links">
            <block type="wishlist/links" name="wishlist_link">
                <action method="setBeforeText">
                    <beforeText><![CDATA[<i class="fa fa-gift"></i>]]>    </beforeText>
                </action>
            </block>
            <action method="addLinkBlock">
                <blockName>wishlist_link</blockName>
            </action>
        </reference>