I need to show an element wrote in HTML into a footer page, only if you're in a specific page ( website homepage, category pages, search results and product pages).
I don't want use statics blocks because the element that I've to show is a simple image with a small amount of text, so the best way that i think to add an "if" that shows the code only if you're in the pages quoted upstairs, but I don't know how can I write the "if condition".
I'm waiting for the answers.
- 
 Which is your Magento version?Khoa Truong– Khoa Truong2016年07月19日 14:44:15 +00:00Commented Jul 19, 2016 at 14:44
- 
 Hi, I'm using Magento ver. 1.9.1.0Dennis_19072016– Dennis_190720162016年07月20日 08:56:41 +00:00Commented Jul 20, 2016 at 8:56
1 Answer 1
You can use the following structures to determine requested page
Mage::app()->getRequest()->getRouteName(); for route name
Mage::app()->getRequest()->getActionName(); for action name
Mage::app()->getRequest()->getControllerName(); for controller name
Mage::app()->getRequest()->getControllerModule(); for module with namespace
Mage::getSingleton('cms/page')->getIdentifier(); for id of cms page 
for example if you need to output your cms block only on Terms and Conditions page you can use
<?php if(Mage::app()->getRequest()->getControllerModule() == 'Mage_Cms' && Mage::getSingleton('cms/page')->getIdentifier() == 'terms-and-conditions'): ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_cms_block_identifier')->toHtml() ?>
<?php endif;?>
in app/design/frontend/your_package/your_theme/default/template/page/html/footer.phtml
Hope it will be usefull for you.
- 
 Hi, thank you for the reply. Unfortunately I don't understand well (I don't know a lot about php) how can I write down the php code, I tried it but it doesn't work. May you help me?Dennis_19072016– Dennis_190720162016年07月20日 08:55:33 +00:00Commented Jul 20, 2016 at 8:55