I want to create a function that can be accessed by all *.phtml files. Where should i place this function in the magento framework?
For down and dirty things, you can always define it in index.php. for example, I always put this function there:
function dumpit($obj)
{
print '<pre>';
print_r($obj);
print '</pre>';
}
Then you can quickly call this routine from anywhere, without having to remember all the other overhead function names to get at the helper.
You should create a module and a helper class in that module (Usually MyCompany_Mymodule_Helper_Data
by default). Then, add your function to that helper class. You can get to that function in your PHTML like this:
Mage::helper("mymodule")->someFunction();
Hope that helps!
Thanks, Joe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With