Magento:使用liParams将类添加到顶部链接

时间:2014-04-17 13:05:35

标签: magento

我尝试使用liParams添加类,但这并未添加到所有链接中。比方说,如果我在标题中有3个链接作为顶部链接,则该类仅添加到第二个链接。第一个和最后一个链接被忽略。 参考:http://www.apptha.com/blog/how-to-add-or-edit-top-links-sections-in-magneto/

现在,问题是我在标题中只有两个顶部链接,因此,类没有被添加到它们中。是否可以在这两个链接中添加类?如果是,请建议必要的更改。在此先感谢您的帮助!

这是我一直在尝试的代码..

<customer_logged_out>   
    <reference name="top.links">
        <action method="addLink" translate="label title" module="customer"><label>LOG IN</label><url helper="customer/getLoginUrl"/><title>LOG IN</title><prepare/><urlParams/><position>200</position><liParams>class="li-logged-out"</liParams><aParams>class="a-logged-out"</aParams></action>
        <action method="addLink" translate="label title" module="customer"><label>SIGN UP</label><url helper="customer/getRegisterUrl"/><title>SIGN UP</title><prepare/><urlParams/><position>100</position><liParams>class="li-logged-out"</liParams><aParams>class="a-logged-out"</aParams></action>
    </reference>    
</customer_logged_out>

1 个答案:

答案 0 :(得分:0)

答案是links.phtml文件默认添加“first”和“last”类名,它们会覆盖你要添加的值。进入你的主题模板/ page / template / links.phtml的副本并从那里修复它。

我假设有.first.last类名来帮助设置链接的样式。 我认为典型的情况是添加边距,但是为了防止边距在第一个链接之前和最后一个链接之后占用空间,例如:

.link { margin: 0 15px; }
.link.first { margin-left: 0; }
.link.last { margin-right: 0; }

在这种情况下,您可以通过CSS略微不同的方法来实现这些冗余:

.link { margin-left: 30px }
.link:first-child { margin-left: 0; }