Helpers are static classes used to perform common functions. Helpers often complement another class. For example, the static JToolBarHelper
helper class works in conjunction with the JToolBar
class.
Note
There are forty-nine helper classes in the Joomla! core alone. For more information, go to http://api.joomla.org/li_Joomla-Framework.html.
When we are building helpers that complement another class, the functions that we place within the helpers must relate to the other class.
Imagine we have a class named SomeItem
, which deals with an itemized entity. If each item were to have a category, we might want to get a list of those categories especially for use with the item.
Placing a method to do this in the SomeItem
class is questionable because the method is dealing with a different entity. Instead, we could create a helper class, SomeItemHelper
, and define a method, getCategories()
, that returns an XHTML drop-down list of categories.
Helpers that do not relate to other classes generally...