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 be able 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 relate to an extension or a library.
Many of the core modules define and use a helper class. This diagram illustrates how
the helper for the Poll module is constructed:
Note that there are some special rules we follow when creating helpers for modules;
these are explained in Chapter 5.
This list describes common functions that helpers execute:
Getting a list (usually an array) of items, often called getList()
Getting or building a data item
Getting or building a data structure
Parsing data
Rendering data to XHTML, often called render()
??? ??? ??? ??? ???
Chapter 7
[ 169 ]
When we use helpers in components, we can use the JView loadHelper() method.
Pages:
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238