获取Magento xml中的基本URL



我正试图通过我的page.xml:添加到footer_menu块的链接

            <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links-follow.phtml">
                <action method="addLink" translate="label title">
                    <label>Condiciones generales</label>
                    <url>legal</url>
                    <title>Condiciones generales</title>
                </action>
            </block>

但是,很明显,路径是相对于它显示的页面的。由于主页url必然会发生变化(从位于/foo/到位于根/),我想预先设置商店的基本url,使其自动工作。

我发现将<urlParams helper="core/url/getHomeUrl" />添加到混合物中可以完成任务。遵循元素的顺序是至关重要的(如果你问我的话,这很令人困惑)。

            <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links-follow.phtml">
                <action method="addLink" translate="label title">
                    <label>Condiciones generales</label>
                    <url>legal</url>
                    <title>Condiciones generales</title>
                    <urlParams helper="core/url/getHomeUrl" />
                </action>
            </block>

希望这能有所帮助。

此方法工作良好

我正在使用{{baseUrl}}在layout.xml文件中获取基本url,以便在客户/帐户/登录url 中添加规范url

<reference name="head">
    <action method="addLinkRel">
        <rel>canonical</rel>
        <href>{{baseUrl}}customer/account/login</href>
    </action>
</reference>

最新更新