How to get current page in magento
Sometimes we reqiure for specific module for specific page. e.g. we want to show bestseller products on home page only and not any other... In this situation we need home page condition. Get current page is home page and display bestseller products on there. Here i have given code that return current page or current module name.
To Get the name of the current router use below code :
Mage::app()->getFrontController()->getRequest()->getModuleName();
If current page is CMS page thene use below to get identifier :
Mage::getSingleton('cms/page')->getIdentifier();
To get the current page url use below code :
Mage::helper('core/url')->getCurrentUrl();
Example : suppose we want to display specific code for home page....
if(Mage::getSingleton('cms/page')->getIdentifier() == 'home'){
Write your code here...
}
To Get the full action name
Mage::app()->getFrontController()->getAction()->getFullActionName()