Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

magento

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?

like image 530
Marlon Creative Avatar asked Sep 03 '10 12:09

Marlon Creative


2 Answers

OK, figured it out myself using trial and error:

$pageTitle = Mage::getModel('cms/page')->load('about-magento-demo-store', 'identifier')->getTitle();
like image 64
Marlon Creative Avatar answered Dec 02 '22 16:12

Marlon Creative


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

<?php $pageTitle = Mage::getSingleton('cms/page')->getIdentifier(); ?>
<?php if ($pageTitle=='home'):?>
like image 27
Guillermo Avatar answered Dec 02 '22 16:12

Guillermo