Let’s say you are working within a specific phtml template file, that is associated with the module name mymodule and class myclass. Suppose you observe the following class function being used:
1 |
echo $this->getAwesomeLink(); |
Now let’s say you are working within another file somewhere and you want to access the awesome link. The problem is that you can no longer reference the desired class via the $this object.
What you need to do is instantiate the class as a variable, and then you can reference the member functions via that variable, the same way you would reference the $this variable in the original phtml file.
Here’s how to do that:
1 2 |
$block = Mage::app()->getLayout()->createBlock('mymodule/myclass'); echo $block->getAwesomeLink(); |