Magento CMS 页面 —从 URL 键/标识符获取标题?
如果您只知道 url 键/标识符,有没有办法获取 cms 页面的标题?例如,关于页面(在示例数据中)的 URL 键/标识符为“about-magento-demo-store”。如果这是我拥有的唯一信息,我将如何从中获取页面标题?如下面的伪代码所示:
$pageTitle = Mage::getModel('cms/page')->loadByAttribute('identifier', 'about-magento-demo-store')->getTitle();
我想仅使用 url 键/标识符来获取所有 CMS 页面标题的列表。
我知道您可以使用以下命令获取当前 CMS 页面标题:
$pageTitle = Mage::getSingleton('cms/page')->getTitle();
有人有什么想法吗?
Is there any way to get the title of a cms page, if you only know it's url key/identifier? For example, the about page (in the sample data) has a url key/identifier of 'about-magento-demo-store'. If that's the only information I had, how would I go about getting the page title from that? As in the faux code below:
$pageTitle = Mage::getModel('cms/page')->loadByAttribute('identifier', 'about-magento-demo-store')->getTitle();
I'd like to get a list of all CMS page titles, using just the url keys/identifiers.
I know you can get the current CMS page title using the following:
$pageTitle = Mage::getSingleton('cms/page')->getTitle();
Anyone any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,通过反复试验我自己弄清楚了:
OK, figured it out myself using trial and error:
我做了这个解决方案来获取页面的 URL-Key(标识符):
I made this solution to get URL-Key (Identifier) of a page: