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 ?


1 Answer 1


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:

    <reference ...

For CMS pages:

$pageId = Mage::getSingleton('cms/page')->getId() // use getIdentifie‌​r()
  • Awesome, that's what I needed. I will accept your answer when I can in 4 minutes.
    – twan
    Jun 28, 2017 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.