Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - create a helper class

I'm having trouble figuring out how to create a helper class with a function in it that's available to *.phtml files.

Can someone describe step by step how I can make the function prtHelloWorld() available to all my *.phtml files?

like image 580
John Avatar asked Jan 27 '11 04:01

John


1 Answers

it's rather simple and you have to call your helper from template like this:

Mage::helper('yourmodule/yourclassfile')->prtHelloWorld();

Default helper class is Data and this defaults to Yourmodule/Helper/Data.php

Mage::helper('yourmodule')->prtHelloWorld();
like image 166
Anton S Avatar answered Sep 19 '22 15:09

Anton S