我想通过这种方式从magento助手获取自定义URL:
<action
method="addLink"
translate="label title"
module="customer">
<label>About Us</label>
<url
helper="customer/getAboutUsUrl">
about
</url>
<title>About Us</title>
<prepare/>
<urlParams/>
<position>1</position>
</action>
所以我所做的就是在 Customer Helper Directory 中的本地目录下定义一个函数 getAboutUsUrl()
。但它并没有像我预期的那样返回基本网址。
我需要做什么才能获取包含“关于我们”链接的基本网址?
谢谢
最佳答案
您应该使用 cms/page/getPageUrl
辅助方法并传递 CMS 页面标识符作为其参数,如下例所示:
<action
method="addLink"
translate="label title"
module="customer">
<label>About Us</label>
<url helper="cms/page/getPageUrl"><pageId>about</pageId></url>
<title>About Us</title>
<prepare/>
<position>1</position>
</action>
关于来自辅助函数的 magento Baseurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3805162/