Create a block object inside a phtml template file:
<?php
$myBlockObject = $this->getLayout()->getBlock(“my_block_name”);
echo $myBlockObject->blockFunction();
?>
Insert a phtml template file into another phtml file
<?php echo $this->getLayout()->createBlock(‘core/template’)->setTemplate(‘page/html/someother.phtml’)->toHtml(); ?>
Get current product from registry
<?php
if( Mage::registry(‘current_product’) ){
$product = Mage::registry(‘current_product’);
}
?>
Insert static block into phtml file
<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘block_identifier’)->toHtml();
?>
Get request (querystring) parameter
<?php
$myVar = Mage::app()->getRequest()->getParam(“myVar”);
?>
Get controller name
Can use this to check whether you are on a product or a category page
<?php
if($this->getRequest()->getControllerName()==’product’){
if(Mage::registry(‘current_product’)){
//do something useful
}
}
?>