Joomla HTMLHelper::_ Class Loader Method
The HTMLHelper is utility class for all HTML drawing classes. The _() method of HTMLHelper is a static function that grants quick access to a number of other static methods. The return value of this function depends on the return value of the method resolved by parsing the first parameter.
The HTMLHelper:_() expects its first parameter to be a string of period-separated (dot-separated) values. These values represent a class prefix (optional), a file name, and a method, in that order.
Namespace:
use Joomla\CMS\HTML\HTMLHelper;
For example,
echo HTMLHelper::_('form.token');
The above code will output the return value of token(), found in the folder:
/libraries/src/HTML/Helpers/Form.php
The filename is used to find the file in which the class and method are defined among whatever include paths have been attached to the static HTMLHelper class using HTMLHelper::addIncludePath.
The "/libraries/src/HTML/Helpers" folder is attached to the class by default.
Example:
echo HTMLHelper::_('myExtension.button.submit');
The above code will output the return value of a static method, myExtensionButton::submit(), which should be defined in a file called "button.php," provided that this file exists in the default include path.
Additional Parameters
Any additional parameters passed to HTMLHelper::_() are passed as parameters themselves to the resolved method.
Files or Classes in HTMLHelper
You can check these files in the folder: /libraries/src/HTML/Helpers
Content
It is utility class to fire onContentPrepare for non-article based content.
- HTMLHelper::_('content.prepare', $text);
Date
It is an extended Utility class for handling date display.
- HTMLHelper::_('date.relative', $date);
It is utility class for cloaking email addresses.
- HTMLHelper::_('email.cloak', $mail);
Form
- HTMLHelper::_('form.token');
Links
- HTMLHelper::_('links.link', $link);
List
It is utility class for creating different select lists.
- HTMLHelper::_('list.images', $name);
- HTMLHelper::_('list.positions', $name);
Menu
It is utility class working with menu select lists.
- HTMLHelper::_('menu.menus');
- HTMLHelper::_('menu.menuItems');
- HTMLHelper::_('menu.menuItemList', $name);
Select
It is utility class for creating HTML select lists.
- HTMLHelper::_('select.booleanlist', $name);
- HTMLHelper::_('select.genericlist', $data, $name);
- HTMLHelper::_('select.integerlist', $start, $end, $inc, $name);
- HTMLHelper::_('select.radiolist', $data, $name);
- HTMLHelper::_('select.option', $value, $text = '');
- HTMLHelper::_('select.options', $arr);
StringHelper
- HTMLHelper::_('string.truncate', $text, $length);
Tag
It is utility class for tags.
- HTMLHelper::_('tag.tags');
User
It is utility class working with users.
- HTMLHelper::_('user.groups');
- HTMLHelper::_('user.userlist');