API17:JHtml::
0xenstierna (Talk | contribs) |
0xenstierna (Talk | contribs) |
||
| Line 4: | Line 4: | ||
A class loader method. | A class loader method. | ||
| − | The _ method of JHtml is a static function that grants quick access to a number of other static methods in the Joomla! platform's [[Subpackage_Html/11.1|HTML subpackage]], in particular those classes with the JHtml prefix (i.e. JHtmlBehavior, JHtmlGrid). The return value of this function depends on the return value of the method resolved by parsing the first parameter. | + | The _ method of JHtml is a static function that grants quick access to a number of other static methods in the Joomla! platform's [[Subpackage_Html/11.1|HTML subpackage]], in particular those classes with the JHtml prefix (i.e. [[JHtmlBehavior/11.1|JHtmlBehavior]], [[JHtmlGrid/11.1|JHtmlGrid]]). The return value of this function depends on the return value of the method resolved by parsing the first parameter. |
==== The $key Paremeter ==== | ==== The $key Paremeter ==== | ||
| − | + | JHtml::_() expects its first parameter to be a string of period-separated values representing a class prefix (optional), a file name, and a method, in that order. When only a filename and method are provided, as seen in the first example, the prefix defaults to "JHtml" and the resolved class name will consist of "JHtml<filename>." The filename segment of $key is used to find the file in which the class and method are defined among whatever include paths have been attached to the static JHtml class using [[JHtml::addIncludePath/11.1|JHtml::addIncludePath]]. The "/libraries/joomla/html/html" folder is attached to the JHtml class by default when "/libraries/joomla/html/html.php" is included, but other paths can be added, making the functionality of _ extensible. | |
'''Examples 1:''' | '''Examples 1:''' | ||
| Line 14: | Line 14: | ||
echo JHtml::_('form.token'); | echo JHtml::_('form.token'); | ||
</source> | </source> | ||
| − | The above code will output the return value of JHtmlForm::token | + | The above code will output the return value of [[JHtmlForm::token/11.1|JHtmlForm::token]], found in "/libraries/joomla/html/html/form.php," (which happens to be a hidden form element containing an anti-spoofing token.) |
'''Example 2:''' | '''Example 2:''' | ||
| Line 20: | Line 20: | ||
echo JHtml::_('myExtension.button.push'); | echo JHtml::_('myExtension.button.push'); | ||
</source> | </source> | ||
| − | The above code will output the return value of a static method, myExtensionButton::push(), which | + | The above code will output the return value of a static method, myExtensionButton::push(), which should be defined in a file called "button.php," provided that this file exists in the default include path. |
====Additional Parameters ==== | ====Additional Parameters ==== | ||
Revision as of 19:23, 13 March 2013
JHtml::_
Description
A class loader method.
The _ method of JHtml is a static function that grants quick access to a number of other static methods in the Joomla! platform's HTML subpackage, in particular those classes with the JHtml prefix (i.e. JHtmlBehavior, JHtmlGrid). The return value of this function depends on the return value of the method resolved by parsing the first parameter.
The $key Paremeter
JHtml::_() expects its first parameter to be a string of period-separated values representing a class prefix (optional), a file name, and a method, in that order. When only a filename and method are provided, as seen in the first example, the prefix defaults to "JHtml" and the resolved class name will consist of "JHtml<filename>." The filename segment of $key is used to find the file in which the class and method are defined among whatever include paths have been attached to the static JHtml class using JHtml::addIncludePath. The "/libraries/joomla/html/html" folder is attached to the JHtml class by default when "/libraries/joomla/html/html.php" is included, but other paths can be added, making the functionality of _ extensible.
Examples 1:
echo JHtml::_('form.token');
The above code will output the return value of JHtmlForm::token, found in "/libraries/joomla/html/html/form.php," (which happens to be a hidden form element containing an anti-spoofing token.)
Example 2:
echo JHtml::_('myExtension.button.push');
The above code will output the return value of a static method, myExtensionButton::push(), which should be defined in a file called "button.php," provided that this file exists in the default include path.
Additional Parameters
Any additinal parameters passed to JHtml::_() will be passed as parameters themselves to the resolved method.
Description:JHtml:: [Edit Descripton]
public static function _ ($key)
| Parameter | Type | Default | Description |
|---|---|---|---|
| $key |
- Returns Varies
- Defined on line 77 of libraries/joomla/html/html.php
- Referenced by
- JElementList::_getOptions
- JPaneSliders::_loadBehavior
- JPaneTabs::_loadBehavior
- JHtmlTabs::_loadBehavior
- JHtmlSliders::_loadBehavior
- JHtmlList::accesslevel
- JHtmlJGrid::action
- JHtmlRules::assetFormWidget
- JHtmlAccess::assetgrouplist
- JHtmlSelect::booleanlist
- calendar
- JHtmlBehavior::caption
- JHtmlCategory::categories
- JHtmlList::category
- JHtmlBehavior::combobox
- JElementList::fetchElement
- JHtmlBehavior::formvalidation
- JHtmlBehavior::framework
- JHtmlList::genericordering
- JFormFieldTimezone::getGroups
- JFormFieldTemplateStyle::getGroups
- JFormFieldMenuItem::getGroups
- JFormFieldGroupedList::getGroups
- JFormFieldModuleLayout::getInput
- JFormFieldMedia::getInput
- JFormFieldList::getInput
- JFormFieldGroupedList::getInput
- JFormFieldComponentLayout::getInput
- JFormFieldCombo::getInput
- JFormFieldCalendar::getInput
- JFormFieldAccessLevel::getInput
- JFormFieldUsergroup::getInput
- JFormFieldUser::getInput
- JFormFieldRules::getInput
- JPagination::getLimitBox
- JFormFieldSQL::getOptions
- JFormFieldSessionHandler::getOptions
- JFormFieldRadio::getOptions
- JFormFieldList::getOptions
- JFormFieldInteger::getOptions
- JFormFieldFolderList::getOptions
- JFormFieldFileList::getOptions
- JFormFieldContentLanguage::getOptions
- JFormFieldCheckboxes::getOptions
- JFormFieldCacheHandler::getOptions
- JFormFieldCategory::getOptions
- JFormFieldMenu::getOptions
- JHtmlList::images
- JHtmlSelect::integerlist
- JHtmlAccess::level
- JHtmlMenu::linkoptions
- JHtmlMenu::menuitemlist
- JHtmlMenu::menuitems
- JHtmlBehavior::modal
- JHtmlCategory::options
- JPagination::orderDownIcon
- JHtmlList::ordering
- JHtmlMenu::ordering
- JPagination::orderUpIcon
- JHtmlList::positions
- script
- JHtmlBehavior::switcher
- JHtmlBehavior::uploader
- JHtmlAccess::usergroup
- JHtmlList::users
See also
-
JHtml::_ source code on BitBucket
-
Class JHtml
-
Subpackage Html
- Other versions of JHtml::_
SeeAlso:JHtml:: [Edit See Also]
User contributed notes
<CodeExamplesForm />
