How to add font awesome icons in top links of Magento

MyraGe picture MyraGe · Jun 9, 2014 · Viewed 8.8k times · Source

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

Answer

Dakshika picture Dakshika · Jun 9, 2014

best practice is use xml for custom modifications. but in this case you need to add on links. try to edit top.links.phtml..you can call class using this

 <action method="addLink" translate="label title" module="customer">
 <label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
<beforeText><![CDATA[<span>]]></beforeText>
<afterText><![CDATA[</span>]]></afterText>
 </action>