API17:JHtml::
(Layout updates) |
0xenstierna (Talk | contribs) |
||
| (8 intermediate revisions by 2 users not shown) | |||
| Line 2: | Line 2: | ||
=={{JVer|11.1}} JHtml::_== | =={{JVer|11.1}} JHtml::_== | ||
===Description=== | ===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 [[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 ==== | ||
| + | |||
| + | 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 below, 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. | ||
| + | |||
| + | '''Example 1:''' | ||
| + | <source lang="php"> | ||
| + | echo JHtml::_('form.token'); | ||
| + | </source> | ||
| + | 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:''' | ||
| + | <source lang="php"> | ||
| + | echo JHtml::_('myExtension.button.submit'); | ||
| + | </source> | ||
| + | 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 additinal parameters passed to JHtml::_() will be passed as parameters themselves to the resolved method. | ||
| + | |||
| + | ==== Caching ==== | ||
| + | |||
| + | Adding many include paths to JHtml::_ could negatively impact its performance, since it has to search through each of those paths in order to find the method that matches the $key string. However, once a particular key has been used to invoke a method, that key and its corresponding [http://php.net/manual/en/language.types.callable.php callable] array are cached. As a result, any future calls using that key will execute much faster. | ||
{{Description:JHtml::_}} | {{Description:JHtml::_}} | ||
| Line 8: | Line 34: | ||
<nowiki>[</nowiki>[[Description:JHtml::_|Edit Descripton]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[Description:JHtml::_|Edit Descripton]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
| − | |||
<source lang="php"> | <source lang="php"> | ||
| − | public static | + | public static function _ ($key) |
</source> | </source> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 25: | Line 50: | ||
|- | |- | ||
|} | |} | ||
| − | + | * '''Returns''' Varies | |
| + | * '''Defined''' on line 77 of libraries/joomla/html/html.php | ||
| + | * '''Referenced by''' | ||
| + | ** [[JElementList::_getOptions/11.1|JElementList::_getOptions]] | ||
| + | ** [[JPaneSliders::_loadBehavior/11.1|JPaneSliders::_loadBehavior]] | ||
| + | ** [[JPaneTabs::_loadBehavior/11.1|JPaneTabs::_loadBehavior]] | ||
| + | ** [[JHtmlTabs::_loadBehavior/11.1|JHtmlTabs::_loadBehavior]] | ||
| + | ** [[JHtmlSliders::_loadBehavior/11.1|JHtmlSliders::_loadBehavior]] | ||
| + | ** [[JHtmlList::accesslevel/11.1|JHtmlList::accesslevel]] | ||
| + | ** [[JHtmlJGrid::action/11.1|JHtmlJGrid::action]] | ||
| + | ** [[JHtmlRules::assetFormWidget/11.1|JHtmlRules::assetFormWidget]] | ||
| + | ** [[JHtmlAccess::assetgrouplist/11.1|JHtmlAccess::assetgrouplist]] | ||
| + | ** [[JHtmlSelect::booleanlist/11.1|JHtmlSelect::booleanlist]] | ||
| + | ** [[calendar/11.1|calendar]] | ||
| + | ** [[JHtmlBehavior::caption/11.1|JHtmlBehavior::caption]] | ||
| + | ** [[JHtmlCategory::categories/11.1|JHtmlCategory::categories]] | ||
| + | ** [[JHtmlList::category/11.1|JHtmlList::category]] | ||
| + | ** [[JHtmlBehavior::combobox/11.1|JHtmlBehavior::combobox]] | ||
| + | ** [[JElementList::fetchElement/11.1|JElementList::fetchElement]] | ||
| + | ** [[JHtmlBehavior::formvalidation/11.1|JHtmlBehavior::formvalidation]] | ||
| + | ** [[JHtmlBehavior::framework/11.1|JHtmlBehavior::framework]] | ||
| + | ** [[JHtmlList::genericordering/11.1|JHtmlList::genericordering]] | ||
| + | ** [[JFormFieldTimezone::getGroups/11.1|JFormFieldTimezone::getGroups]] | ||
| + | ** [[JFormFieldTemplateStyle::getGroups/11.1|JFormFieldTemplateStyle::getGroups]] | ||
| + | ** [[JFormFieldMenuItem::getGroups/11.1|JFormFieldMenuItem::getGroups]] | ||
| + | ** [[JFormFieldGroupedList::getGroups/11.1|JFormFieldGroupedList::getGroups]] | ||
| + | ** [[JFormFieldModuleLayout::getInput/11.1|JFormFieldModuleLayout::getInput]] | ||
| + | ** [[JFormFieldMedia::getInput/11.1|JFormFieldMedia::getInput]] | ||
| + | ** [[JFormFieldList::getInput/11.1|JFormFieldList::getInput]] | ||
| + | ** [[JFormFieldGroupedList::getInput/11.1|JFormFieldGroupedList::getInput]] | ||
| + | ** [[JFormFieldComponentLayout::getInput/11.1|JFormFieldComponentLayout::getInput]] | ||
| + | ** [[JFormFieldCombo::getInput/11.1|JFormFieldCombo::getInput]] | ||
| + | ** [[JFormFieldCalendar::getInput/11.1|JFormFieldCalendar::getInput]] | ||
| + | ** [[JFormFieldAccessLevel::getInput/11.1|JFormFieldAccessLevel::getInput]] | ||
| + | ** [[JFormFieldUsergroup::getInput/11.1|JFormFieldUsergroup::getInput]] | ||
| + | ** [[JFormFieldUser::getInput/11.1|JFormFieldUser::getInput]] | ||
| + | ** [[JFormFieldRules::getInput/11.1|JFormFieldRules::getInput]] | ||
| + | ** [[JPagination::getLimitBox/11.1|JPagination::getLimitBox]] | ||
| + | ** [[JFormFieldSQL::getOptions/11.1|JFormFieldSQL::getOptions]] | ||
| + | ** [[JFormFieldSessionHandler::getOptions/11.1|JFormFieldSessionHandler::getOptions]] | ||
| + | ** [[JFormFieldRadio::getOptions/11.1|JFormFieldRadio::getOptions]] | ||
| + | ** [[JFormFieldList::getOptions/11.1|JFormFieldList::getOptions]] | ||
| + | ** [[JFormFieldInteger::getOptions/11.1|JFormFieldInteger::getOptions]] | ||
| + | ** [[JFormFieldFolderList::getOptions/11.1|JFormFieldFolderList::getOptions]] | ||
| + | ** [[JFormFieldFileList::getOptions/11.1|JFormFieldFileList::getOptions]] | ||
| + | ** [[JFormFieldContentLanguage::getOptions/11.1|JFormFieldContentLanguage::getOptions]] | ||
| + | ** [[JFormFieldCheckboxes::getOptions/11.1|JFormFieldCheckboxes::getOptions]] | ||
| + | ** [[JFormFieldCacheHandler::getOptions/11.1|JFormFieldCacheHandler::getOptions]] | ||
| + | ** [[JFormFieldCategory::getOptions/11.1|JFormFieldCategory::getOptions]] | ||
| + | ** [[JFormFieldMenu::getOptions/11.1|JFormFieldMenu::getOptions]] | ||
| + | ** [[JHtmlList::images/11.1|JHtmlList::images]] | ||
| + | ** [[JHtmlSelect::integerlist/11.1|JHtmlSelect::integerlist]] | ||
| + | ** [[JHtmlAccess::level/11.1|JHtmlAccess::level]] | ||
| + | ** [[JHtmlMenu::linkoptions/11.1|JHtmlMenu::linkoptions]] | ||
| + | ** [[JHtmlMenu::menuitemlist/11.1|JHtmlMenu::menuitemlist]] | ||
| + | ** [[JHtmlMenu::menuitems/11.1|JHtmlMenu::menuitems]] | ||
| + | ** [[JHtmlBehavior::modal/11.1|JHtmlBehavior::modal]] | ||
| + | ** [[JHtmlCategory::options/11.1|JHtmlCategory::options]] | ||
| + | ** [[JPagination::orderDownIcon/11.1|JPagination::orderDownIcon]] | ||
| + | ** [[JHtmlList::ordering/11.1|JHtmlList::ordering]] | ||
| + | ** [[JHtmlMenu::ordering/11.1|JHtmlMenu::ordering]] | ||
| + | ** [[JPagination::orderUpIcon/11.1|JPagination::orderUpIcon]] | ||
| + | ** [[JHtmlList::positions/11.1|JHtmlList::positions]] | ||
| + | ** [[script/11.1|script]] | ||
| + | ** [[JHtmlBehavior::switcher/11.1|JHtmlBehavior::switcher]] | ||
| + | ** [[JHtmlBehavior::uploader/11.1|JHtmlBehavior::uploader]] | ||
| + | ** [[JHtmlAccess::usergroup/11.1|JHtmlAccess::usergroup]] | ||
| + | ** [[JHtmlList::users/11.1|JHtmlList::users]] | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
===See also=== | ===See also=== | ||
| + | * {{JVer|11.1}} '''JHtml::_ source code''' on [[jplatform:html/html.php#cl-69|BitBucket]] | ||
| + | * {{JVer|11.1}} Class [[JHtml/11.1|JHtml]] | ||
| + | * {{JVer|11.1}} Subpackage [[Subpackage_Html/11.1|Html]] | ||
| + | * [[JHtml::_|Other versions of JHtml::_]] | ||
| + | {{SeeAlso:JHtml::_}} | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[</nowiki>[[SeeAlso:JHtml::_|Edit See Also]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[SeeAlso:JHtml::_|Edit See Also]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
| − | + | ===User contributed notes=== | |
| − | + | ||
| − | + | ||
| − | === | + | |
<CodeExamplesForm /> | <CodeExamplesForm /> | ||
<dpl> | <dpl> | ||
| Line 111: | Line 136: | ||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
| + | namespace=CodeExample | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
<noinclude>[[Category:JHtml]][[Category:JHtml::_]]</noinclude> | <noinclude>[[Category:JHtml]][[Category:JHtml::_]]</noinclude> | ||
Revision as of 11:17, 14 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 below, 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.
Example 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.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 additinal parameters passed to JHtml::_() will be passed as parameters themselves to the resolved method.
Caching
Adding many include paths to JHtml::_ could negatively impact its performance, since it has to search through each of those paths in order to find the method that matches the $key string. However, once a particular key has been used to invoke a method, that key and its corresponding callable array are cached. As a result, any future calls using that key will execute much faster.
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 />
