web hosting
build a website

Magento find what current page you are on to target with code PHP

Aug 16, 2015   //   by Anthony Devine   //   Website Development tips  //  No Comments

Find what current page you are on i.e. checkout/basket page put the following code in the head of the site. This will popup with the name of the page.

<?php $current_page = Mage::app()->getFrontController()->getRequest()->getRouteName(); ?>
<script>alert("<?php echo $current_page; ?>");</script>

Then when you find the page you want to target add this in your header:

<?php $current_page = Mage::app()->getFrontController()->getRequest()->getRouteName(); ?>
if(!$current_page=="checkout"){

code for all meta tags

}