Saturday, November 24, 2007

Magento Getting Page Title

Magento is a great new open-source shopping cart engine written in PHP on top of Zend framework. It is highly configurable. Been trying to do some debugging and learning on the overall flow of things, so for those who are interested, read on...

I'm not yet sure how to get around talking back with the app so I've discovered the use of Mage::Registry(key) which is a central place that stores a lot of current variables during the execution of the request.

To get the title of the current page (as defined in the CMS backend page admin), you can do:
Mage::getSingleton('cms/page')->getTitle() == 'My Title')


Ravinderpal said...

Hi Samir,

Thanks for the tip on how to get the title of a page created using the CMS.

Do you know how to get the title of a page not created using the CMS? For example, how to get the current title of a page already included with Magento.

Thanks for your help.


Steve said...


Depending on the context, you should be able to use the getSingleton method to retrieve the value. For example...


Hope this helps!

Sam said...

You can also do this, same difference really:


Neil Van said...

Or do it like this:
in a BLOCK