Posts tagged ‘Helpers’
Helpers
Helpers in Magento are simply a way to abstract (or refactor) utility methods out of core classes. Most access to helpers are doubly wrapped up inside various Block and Model methods anyway, so the value of helpers is pretty dubious. Very rarely do you want to override or sub-class a helper. It is very easy to simply add a new helper to provide additional utility functionality to your scripts. The two major methods of helpers that you should be interested in are:
• __ (just two underscores)
• htmlEscape
The double underscore method __ is a translation helper. This helper function is wrapped from almost any object context, which means you can safely call $this->__(’My English Text’) at almost any point in your code to translate a string. The htmlEscape function simply wraps PHP’s native htmlspecialchars function, but it can also accept an array of data and escape each item individually.
Recent Comments