【发布时间】:2011-11-26 14:39:51
【问题描述】:
我正在尝试做一些看起来应该很简单的事情:在每个页面上添加一个“主页”链接到我的 top.links 除了主页(我使用 cms 页面作为我的主页)。如果可能,我想完全在我的 local.xml 中执行此操作。
我的想法是默认添加链接
<default>
<reference name="top.links">
<action method="addLink" translate="label title">
<label>Home</label>
<url>/</url>
<title>Home</title>
<prepare>true</prepare>
<urlParams helper="core/url/getHomeUrl"/>
<position>1</position>
<liParams/>
<aParams>class="top-link-home"</aParams>
<beforeText></beforeText>
<afterText> / </afterText>
</action>
</reference>
</default>
然后在 cms_index_index 上删除它
<cms_index_index>
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="core/url/getHomeUrl"/></action>
</reference>
</cms_index_index>
但这并没有奏效,主页链接显示在任何地方,包括主页上。
我做错了什么?还有其他不涉及黑客核心的方法吗?
编辑: 通过在我的 addLink 中拼出整个 url,我得到了所需的行为
<default>
<reference name="top.links">
<action method="addLink" translate="label title">
<label>Home</label>
<url>http://www.mysite.com/</url>
<title>Home</title>
<prepare/>
<urlParams/>
<position>1</position>
<liParams/>
<aParams>class="top-link-home"</aParams>
<beforeText></beforeText>
<afterText> / </afterText>
</action>
</reference>
</default>
还有我的 removeLinkByUrl
<cms_index_index>
<reference name="top.links">
<action method="removeLinkByUrl"><url>http://www.mysite.com/</url></action>
</reference>
</cms_index_index>
解决了手头的问题,但没有回答我原来的问题。我想我需要更好地了解 Magento 如何使用助手呈现 url。
【问题讨论】:
-
问题来自 Magento 添加 SID 参数。它没有被渲染,我不知道为什么它需要在这种情况下出现。我稍后会研究这个
标签: xml magento magento-1.5