开发者

Magento CMS pages — getting title from URL key/identifier?

开发者 https://www.devze.com 2023-01-14 13:42 出处:网络
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\'. I

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?


OK, figured it out myself using trial and error:

$pageTitle = Mage::getModel('cms/page')->load('about-magento-demo-store', 'identifier')->getTitle();


I made this solution to get URL-Key (Identifier) of a page:

<?php $pageTitle = Mage::getSingleton('cms/page')->getIdentifier(); ?>
<?php if ($pageTitle=='home'):?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号