Saturday, December 14, 2013

current URL in Magento

<?php

$currentUrl = $this->helper('core/url')->getCurrentUrl();

?>



<?php
$current_page = '';
/*
* CMS page
* get the page identifier
*/
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'):
$current_page = Mage::getSingleton('cms/page')->getIdentifier();
endif;
/*
* If not CMS page, 
* get the route name
*/
if(empty($current_page)):
$current_page = Mage::app()->getFrontController()->getRequest()->getRouteName();
endif;
/*
* catalog page
* get the category path :)
*/
if($current_page == 'catalog'):
$current_page = 'categorypath-' . preg_replace('#[^a-z0-9]+#', '-', strtolower(Mage::registry('current_category')->getUrlPath()));
endif;
?>

About

Blogger templates