2013-05-07 74 views
1

我怎样才能添加其他元素,以便我能得到这个树状结构<ul><li><span><a>Logout</a></span></li></ul>如何在list.links之后的list.links中添加另一个HTML元素?后<code><li></code></p> <p>不添加链接

目前我呈现的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然后更改将适用于所有的链接,否则我需要如果其他人在那里,但我只需要注销。那么最好的办法是什么?

这是可以使用addLinks方法吗?

回答

3

您可以在此使用beforeTextafterText参数,这样做:

<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> 
+0

真棒。谢谢 – RIK 2013-05-13 15:05:47

0

您可以创建自己的模板( links.phtml的副本)并仅将其应用于热门链接。 像这样做在你的主题local.xml中:

<default> 
    <reference name="top.links"> 

     <action method="setTemplate"> 
      <template>page/template/my_links.phtml</template> 
     </action> 

    </reference> 
<default> 

然后复制页/模板/ links.phtml和其重命名为页/模板/ my_links.phtml,做任何你需要内部的新的模板文件。它将只用于渲染顶部链接,而不是用于任何其他链接。

+0

他试图针对一个特定的链接,而不是所有的链接。 – Axel 2013-05-13 15:07:40

相关问题