PHP Magento Tips

Reorder and add Additional Class to Top Links in Magento

Rate this posting:
{[['']]}

Add below code in your local.xml file to Reorder and add Additional Class to Top Links in Magento.

<?xml version="1.0"?>
<!--
    [Your site name] XML overrides
-->
<layout version="0.1.0">
    <!-- updating top.links to add class names -->
        <!-- Section 1: Removing Current Links -->
        <default>
            <reference name="top.links">
                <!-- Removes 'My Account' link  -->
                <action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>
                <!-- Removes 'My Cart' AND 'Checkout' links -->
                <remove name="checkout_cart_link" />
            </reference>
        </default>
        <customer_logged_out>
            <!-- Removes 'Log In' link -->
            <reference name="top.links">
                <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
                <action method="removeLinkByUrl"><url helper="customer/getRegisterUrl"/></action>
            </reference>
        </customer_logged_out>
        <customer_logged_in>
            <!-- Removes 'Log Out' link -->
            <reference name="top.links">
                <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
            </reference>
        </customer_logged_in>
        <!-- Section 2: Adding New Links -->
        <!-- order can be easily edited here by changing the position number -->
        <default>
            <reference name="top.links">
                <!-- add My Account -->
                <!-- default position 10 -->
                <action method="addLink" translate="label title" module="customer">
                    <label>My Account</label>
                    <url helper="customer/getAccountUrl"/>
                    <title>My Account</title>
                    <prepare/>
                    <urlParams/>
                    <position>10</position>
                    <liParams>
                        <class>top-account</class>
                    </liParams>
                    <aParams>
                        <class>top-account-a</class>
                    </aParams>
                    <beforeText/>
                    <afterText/>
                </action>
                <!-- add My Wishlist -->
                <!-- default position 20 -->
                <reference name="wishlist_link">
                    <action method="setLiParams"><params>class="top-wishlist"</params></action>
                    <action method="setAParams"><params>class="top-wishlist-a"</params></action>
                </reference>
                <!-- add My Cart -->
                <!-- default position 40 -->
                <block type="checkout/links" name="checkout_cart_link_custom">
                    <action method="addCartLink"></action>
                </block>
                <!-- add Checkout -->
                <!-- default position 50 -->
                <action method="addLink" translate="label title">
                    <label>Checkout</label>
                    <url>/checkout</url>
                    <title>Checkout</title>
                    <prepare />
                    <urlParams/>
                    <position>50</position>
                    <liParams>
                        <class>top-checkout</class>
                    </liParams>
                    <aParams>
                        <class>top-checkout-a</class>
                    </aParams>
                    <beforeText />
                    <afterText />
                </action>
            </reference>
        </default>
        <customer_logged_out>
            <!-- add Log In (when customer is not logged in) -->
            <reference name="top.links">
                <action method="addLink" translate="label title" module="customer">
                    <label>Log In</label>
                    <url helper="customer/getAccountUrl"/>
                    <title>Log In</title>
                    <prepare/>
                    <urlParams/>
                    <position>70</position>
                    <liParams>
                        <class>top-log-in</class>
                    </liParams>
                    <aParams>
                        <class>top-log-in-a</class>
                    </aParams>
                    <beforeText />
                    <afterText />                   
                </action>
            </reference>
            <!-- add Register (when customer is not logged in) -->
            <reference name="top.links">
                <action method="addLink" translate="label title" module="customer">
                    <label>Register</label>
                    <url helper="customer/getRegisterUrl"/>
                    <title>Register</title>
                    <prepare/>
                    <urlParams/>
                    <position>60</position>
                    <liParams>
                        <class>top-register</class>
                    </liParams>
                    <aParams>
                        <class>top-register-a</class>
                    </aParams>
                    <beforeText />
                    <afterText />                   
                </action>
            </reference>           
        </customer_logged_out>
        <customer_logged_in>
            <!-- add Log Out (when customer is logged in) -->
            <reference name="top.links">
                <action method="addLink" translate="label title" module="customer">
                    <label>Log Out</label>
                    <url helper="customer/getLogoutUrl"/>
                    <title>Log Out</title>
                    <prepare/>
                    <urlParams/>
                    <position>70</position>
                    <liParams>
                        <class>top-log-out</class>
                    </liParams>
                    <aParams>
                        <class>top-log-out-a</class>
                    </aParams>
                    <beforeText />
                    <afterText />
                </action>
            </reference>
        </customer_logged_in>       
</layout>
Tag : Magento
0 Comments On "Reorder and add Additional Class to Top Links in Magento"

Back To Top