如何添加重定向到另一个域的Magento top.links的链接?

时间:2011-03-30 19:53:15

标签: magento-1.4 magento

我可以使用以下代码添加自定义链接到Magento的top.links,我保存在../myCustomTheme / layout / local.xml

<reference name="root">
<reference name="top.links">
    <action method="addLink" translate="label title">
        <label>example</label>
        <url>example</url> 
        <title>example</title>
        <prepare>true</prepare> 
        <urlParams helper="core/url/getHomeUrl"/> 
        <position>100</position>
        <liParams/>
        <aParams>class="top-link-example"</aParams>
        <beforeText></beforeText>
        <afterText></afterText>
    </action>
</reference>
</reference>

上面的代码将创建一个名为example的链接,指向http://myexampledomain.com/example。如果我改变这行代码

<url>example</url>

<url>http://myotherexampledomain.com</url>

我最终得到一个名为example的链接,指向http://myexampledomain.com/http:/myotherexampledomain.com。我已经尝试将prepare参数设置为false并通过查看../app/code/core/Mage/Core/Model/Url.php将各种参数添加到urlParams无效。

1 个答案:

答案 0 :(得分:13)

所以,我坚持到底,我已经开始工作了。基本上,准备工作需要取消设置,因为如果设置为“true”或“false”,它会将URL附加到您站点的基本URL。这是更正后的代码:

<reference name="root">
<reference name="top.links">
    <action method="addLink" translate="label title">
        <label>example</label>
        <url>http://myotherexampledomain.com</url> 
        <title>example</title>
        <prepare/>
        <urlParams/> 
        <position>100</position>
        <liParams/>
        <aParams>class="top-link-example"</aParams>
        <beforeText></beforeText>
        <afterText></afterText>
    </action>
</reference>
</reference>

我还从urlParams中删除了helper =“core / url / getHomeUrl”,因为在这种情况下不需要getHomeUrl函数。上面的代码创建了一个名为example的链接,该链接正确指向http://myotherexapmpledomain.com