There are times when you want to perform some event on particular page.
In Magento to detect the current page, following code can be used.
1) To Get the name of the current router use following code :
There are majorly four routes
a) CMS : It includes all CMS pages
b) Catalog : It includes listing and detail page
c) Checkout : It includes shopping basket, checkout and success page
d) Customer : It includes all customer pages
CMS page : To get the identifier of the current CMS page you can use
To get the Page Title :
To get the Page ID :
Category Page : To get the category name in product listing page use
This code will throw an error on other pages than catalog. So please check the router to be catalog before executing this code.
Also, In the last case you can always use the URL to find on which page you are
Please see my post on URL’s to check How To Get Current URL
To call a phtml template file in another phtml file you can use following code.
<?php echo $this->getLayout()->createBlock(‘core/template’)->setTemplate(‘templateFolder/yourtemplate.phtml’)->toHtml(); ?>