How to get Current page url in magento.

Magento
Get Current page url in magento or you can find catalog url using below code. With the help of this code you can easily find current page url in magento [php] <?php $current_page = ''; /* * Check to see if its a CMS page * if it is then get the page identifier */ if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'): $current_page = Mage::getSingleton('cms/page')->getIdentifier(); endif; /* * If its not CMS page, then just get the route name */ if(empty($current_page)): $current_page = Mage::app()->getFrontController()->getRequest()->getRouteName(); endif; /* * What if its a catalog page? * Then we can get the category path :) */ /* * Or you can check all values * $current_page_array = Mage::registry('current_category'); * $current_page_array['url_path'] */ if($current_page == 'catalog'): $current_page = 'path-' . preg_replace('#[^a-z0-9]+#', '-', strtolower(Mage::registry('current_category')->getUrlPath())); endif; ?> [/php] Also if you…
Read More

Check home page URL in magento

Magento
Check current page is home page in magento If you want to check current page is home page or not in magneto below code is helpful to you. [php] <?php if( Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ?> [/php] The other way you can check current page is home page or not in magento [php] <?php if($this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))): echo "Homepage"; else: echo "Not in Homepage"; endif; ?> [/php] [JWD-Magento-Development]
Read More