jcadima
12/7/2015 - 2:33 PM

Page Conditionals, calling other .phtml templates

Page Conditionals, calling other .phtml templates


http://optimiseblog.co.uk/is-home-page-conditional-or-check-if-you-are-on-the-home-page-in-magento-1-4-1-5/

<?php  //  cms will be equal to the main page on magento
$route = Mage::app()->getFrontController()->getRequest()->getRouteName();
$action = Mage::app()->getFrontController()->getRequest()->getActionName();
if($route == ‘cms’ && $action == ‘index’):
   echo $this->getChildHtml(‘shopper_footer_partners’);
endif;

?>


<?php if( $this->getIsHomePage() ):?>
Your HTML here...
<?php endif; ?>



<?php  
https://universalcoder.wordpress.com/2014/03/07/how-to-get-current-page-url-and-identifiers-in-magento/
// the name of the page will be stored in $homepage
	$homepage = Mage::app()->getFrontController()->getRequest()->getRouteName();
	if( $homepage == 'cms'   )
	echo 'THIS IS THE HOMEPAGE:  ' . $homepage ;
?>


CMS page : To get the identifier of the current CMS page
Mage::getSingleton(‘cms/page’)->getIdentifier();


To get the Page Title :
Mage::getSingleton(‘cms/page’)->getTitle();


To get the Page ID :
Mage::getBlockSingleton(‘cms/page’)->getPage()->getId();


Category Page : To get the category name in product listing page use
Mage::registry(‘current_category’)->getName();
** This code will throw an error on other pages than catalog. So please check 
the router to be catalog before executing this code.


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(); ?>