如何在<li>
所以我可以得到这个树结构<ul><li><span><a>Logout</a></span></li></ul>
目前我呈现的html看起来像这样。我希望有span元素可以通过注销进行更多操作。我已经尝试了很多但没有运气。请帮忙。谢谢
<ul class="links">
<li class="first last">
<a href="http://www.abc.com/index.php/customer/account/logout/" title="Log Out" class="logout-link">Logout</a>
</li>
</ul>
布局 top.links 是
<customer_logged_in>
<reference name="account.links">
<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>
</action>
<action method="removeLinkByUrl">
<url helper="customer/getRegisterUrl" />
</action>
</reference>
如果我要更改 links.phtml ,那么更改将适用于所有链接,否则我需要将if if放在那里,但我只需要注销。那么最好的方法是什么?
这是否可以使用addLinks方法实现?
答案 0 :(得分:3)
您可以使用beforeText
和afterText
参数执行此操作,如下所示:
<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>
将修改您的链接,使其显示如下:
<li class="first last">
<span><a href="http://www.abc.com/index.php/customer/account/logout/" title="Log Out" class="logout-link">Logout</a></span>
</li>
答案 1 :(得分:0)
您可以创建自己的模板(links.phtml的副本)并仅将其应用于Top Links。 在主题的local.xml中这样做:
<default>
<reference name="top.links">
<action method="setTemplate">
<template>page/template/my_links.phtml</template>
</action>
</reference>
<default>
然后复制 page / template / links.phtml 并将其重命名为 page / template / my_links.phtml ,并在新模板文件中执行您需要的任何操作。它仅用于渲染Top Links,而不用于任何其他链接