如何分别添加css登录,注册和注销链接?

时间:2013-04-29 15:55:20

标签: magento

我正在尝试为登录注册和登录链接提供不同的CSS。但是当使用template_links块添加它们并且它们被自动呈现并且没有特定的模板文件时,我无法实现这一点。

 <block type="page/template_links" name="account.links" as="accountLinks"/>

目前我尝试更改css,但显然css规则同时被分配给所有这些。

我怎样才能做到这一点请提出建议。谢谢

我可以使用布局吗?

    <customer_logged_in>
        <reference name="account.links">
            <action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>2</position></action>
            <action method="removeLinkByUrl"><url helper="customer/getRegisterUrl" /></action>
        </reference>
    </customer_logged_in>

<!--
Load this update on every page when customer is logged out
-->

    <customer_logged_out>
        <reference name="account.links">
            <action method="addLink" translate="label title" module="customer"><label>Login</label><url helper="customer/getLoginUrl"/><title>Login</title><prepare/><urlParams/><position>1</position></action>
            <action method="removeLinkByUrl" ifconfig="enterprise_invitation/general/registration_required_invitation"><url helper="customer/getRegisterUrl" /></action>
            <!-- <action method="addLink" translate="label title" module="customer"><label>register</label><url helper="customer/getRegisterUrl" /><title>register</title><prepare/><urlParams/><position>100</position><li/><a/><before_text> or </before_text><after_text>.</after_text></action> -->
        </reference>
        <remove name="wishlist_sidebar"></remove>
        <remove name="reorder"></remove>
        <remove name="top.menu" />
    </customer_logged_out>

<!--
Layout for customer login page
-->

    <customer_account_login translate="label">
        <label>Customer Account Login Form</label>
        <!-- Mage_Customer -->
        <remove name="right"/>
        <remove name="left"/>
        <reference name="head">
            <action method="addJs"><script>jquery/jquery.js</script></action>
        </reference>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/> 
        </reference>
    </customer_account_login>

目前的主题链接看起来像这样

enter image description here

------ ----- EDIT

将类放入aparam之后它仍然应用与html中相同的旧css规则,不显示类元素。我已将.logout-link类放在custom和style.css中的相同主题中,但仍然没有运气。它没有找到这个类,甚至没有在chrome开发人员工具中显示。

<customer_logged_in>
<reference name="account.links">
    <action method="addLink" translate="label title" module="customer">
        <label>Log Out</label>
        <url helper="customer/getLogoutUrl"/>
        <title>Log Out</title>
        <prepare/>
        <urlParams/>
        <position>2</position>
        <aParams>class="logout-link"</aParams>
        </action>
    <action method="removeLinkByUrl"><url helper="customer/getRegisterUrl" /></action>
</reference>

<div class="header-links-wrapper">
        <ul class="links">
                    <li class="first last"><a href="http://www.ubt.com/index.php/customer/account/logout/" title="Log Out">Log Out</a></li>
        </ul>
    </div>

1 个答案:

答案 0 :(得分:2)

您可以使用以下方法应用addLink方法的类:

<liParams/>
<aParams>class="My Class Name"</aParams>
<beforeText/>
<afterText/>

例如,要在您的注销链接中添加一个类,您可以执行以下操作:

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

然后你只需为logout-link

添加一个css定义