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

JP1*_*971 8 magento magento-1.4

我可以使用以下代码将自定义链接添加到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>
Run Code Online (Sandbox Code Playgroud)

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

<url>example</url>
Run Code Online (Sandbox Code Playgroud)

<url>http://myotherexampledomain.com</url>
Run Code Online (Sandbox Code Playgroud)

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

JP1*_*971 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>
Run Code Online (Sandbox Code Playgroud)

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