Magento – How to check if page has certain ID

categorymagento-1.9PHP

I have a page that needs to behave a little different than similair pages, so I want to add an if else statement for only one ID. How can I do that for magento 1.9?

On the view.phtml I need to add something like:

if($pageid == 44){
    echo 'do this';
}

What do I add for $pageid ?

Best Answer

If it is an URL parameter you can use

$pageId = Mage::app()->getRequest()->getParam('pageid', 0)

For pages:

$pageId = Mage::registry('current_category')->getId()

You can also modify your single category from your_layout.xml Layout handles for categoris look like:

<CATEGORY_{yourId}>
    <reference ...

For CMS pages:

$pageId = Mage::getSingleton('cms/page')->getId() // use getIdentifie‌​r()
Related Topic