如何在magento中获取特定的页面URL [英] How to get particular page URL in magento

查看:80
本文介绍了如何在magento中获取特定的页面URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Magento中获取页面的URL密钥.

I would like to get a page's URL key in Magento.

例如,我有一个名为新功能"的CMS页面,其标识符(或URL密钥)为"whats_new".因此,其正确的URL为http://mysite.com/whats_new

For example, I have a CMS page called "What's New" with the identifier (or URL key) "whats_new". Its correct URL is therefore http://mysite.com/whats_new

当前,我使用以下代码来回显其位置:

Currently I use this code to echo its location:

<?php echo Mage::getBaseUrl();?>whats_new

我觉得这是一种不好的做法,因为它的标识符(或URL密钥)是可管理的;如果其URL密钥或标识符更改,则链接将断开.呼应其动态URL密钥的正确方法是什么?也许类似于Wordpress的get_permalink('10')?

I feel it's bad practice because its identifier (or URL key) is administrable; if its URL key or identifier changes then the link will break. What is the proper way to echo its dynamic URL key? Perhaps something similar to Wordpress's get_permalink('10')?

推荐答案

我认为这将满足您的要求:

I think this will do what you want:

<?php echo Mage::helper('cms/page')->getPageUrl( $pageId ) ?>

用链接页面的正确ID替换$pageId,它应该可以工作.

Replace $pageId with the correct id for the page you are linking to and it should work.

这篇关于如何在magento中获取特定的页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆