我正在嘗試做一些看起來應該很簡單的事情:在每頁的頂部鏈接上添加一個「主頁」鏈接,除了主頁(我正在使用cms頁面作爲我的主頁)。如果可能,我想完全在我的local.xml中完成。如何通過Magento 1.5.1中的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>
但這並沒有奏效,在主頁的鏈接處處顯示出來,包括主頁。
我在做什麼錯?有沒有另一種方法可以做到這一點,不涉及黑客攻擊?
編輯: 我拼寫出整個URL所期望的行爲,無論是在我的addLink
<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如何使用助手呈現網址。
問題來自Magento添加SID參數。它沒有被渲染,我不知道爲什麼它需要在這種情況下。我將在稍後討論這個問題 – benmarks