0

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.

asked Jul 19, 2016 at 14:21
2
  • Which is your Magento version? Commented Jul 19, 2016 at 14:44
  • Hi, I'm using Magento ver. 1.9.1.0 Commented Jul 20, 2016 at 8:56

1 Answer 1

0

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.

answered Jul 19, 2016 at 15:03
1
  • 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? Commented Jul 20, 2016 at 8:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.