API17

Difference between revisions of "JHtml::"

From Joomla! Documentation

m (JoomlaWikiBot moved page JHtml:: /11.1 to API17:JHtml:: without leaving a redirect: Robot: Moved page)
m (preparing for archive only)
 
(3 intermediate revisions by the same user not shown)
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/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 _ method of JHtml is a static function that grants quick access to a number of other static methods in the Joomla! platform's [[API17:Subpackage_Html|HTML subpackage]], in particular those classes with the JHtml prefix (i.e. [[API17:JHtmlBehavior|JHtmlBehavior]], [[API17:JHtmlGrid|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 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.
+
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 [[API17:JHtml::addIncludePath|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:'''
 
'''Example 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/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.)
+
The above code will output the return value of [[API17:JHtmlForm::token|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 30: Line 30:
 
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.
 
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::_}}
+
 
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[</nowiki>[[Description:JHtml::_|Edit Descripton]]<nowiki>]</nowiki>
 
</span>
 
 
<source lang="php">
 
<source lang="php">
 
public static function _ ($key)
 
public static function _ ($key)
Line 53: Line 51:
 
* '''Defined''' on line 77 of libraries/joomla/html/html.php
 
* '''Defined''' on line 77 of libraries/joomla/html/html.php
 
* '''Referenced by'''
 
* '''Referenced by'''
** [[JElementList::_getOptions/11.1|JElementList::_getOptions]]
+
** [[API17:JElementList::_getOptions|JElementList::_getOptions]]
** [[JPaneSliders::_loadBehavior/11.1|JPaneSliders::_loadBehavior]]
+
** [[API17:JPaneSliders::_loadBehavior|JPaneSliders::_loadBehavior]]
** [[JPaneTabs::_loadBehavior/11.1|JPaneTabs::_loadBehavior]]
+
** [[API17:JPaneTabs::_loadBehavior|JPaneTabs::_loadBehavior]]
** [[JHtmlTabs::_loadBehavior/11.1|JHtmlTabs::_loadBehavior]]
+
** [[API17:JHtmlTabs::_loadBehavior|JHtmlTabs::_loadBehavior]]
** [[JHtmlSliders::_loadBehavior/11.1|JHtmlSliders::_loadBehavior]]
+
** [[API17:JHtmlSliders::_loadBehavior|JHtmlSliders::_loadBehavior]]
** [[JHtmlList::accesslevel/11.1|JHtmlList::accesslevel]]
+
** [[API17:JHtmlList::accesslevel|JHtmlList::accesslevel]]
** [[JHtmlJGrid::action/11.1|JHtmlJGrid::action]]
+
** [[API17:JHtmlJGrid::action|JHtmlJGrid::action]]
** [[JHtmlRules::assetFormWidget/11.1|JHtmlRules::assetFormWidget]]
+
** [[API17:JHtmlRules::assetFormWidget|JHtmlRules::assetFormWidget]]
** [[JHtmlAccess::assetgrouplist/11.1|JHtmlAccess::assetgrouplist]]
+
** [[API17:JHtmlAccess::assetgrouplist|JHtmlAccess::assetgrouplist]]
** [[JHtmlSelect::booleanlist/11.1|JHtmlSelect::booleanlist]]
+
** [[API17:JHtmlSelect::booleanlist|JHtmlSelect::booleanlist]]
** [[calendar/11.1|calendar]]
+
** [[calendar|calendar]]
** [[JHtmlBehavior::caption/11.1|JHtmlBehavior::caption]]
+
** [[API17:JHtmlBehavior::caption|JHtmlBehavior::caption]]
** [[JHtmlCategory::categories/11.1|JHtmlCategory::categories]]
+
** [[API17:JHtmlCategory::categories|JHtmlCategory::categories]]
** [[JHtmlList::category/11.1|JHtmlList::category]]
+
** [[API17:JHtmlList::category|JHtmlList::category]]
** [[JHtmlBehavior::combobox/11.1|JHtmlBehavior::combobox]]
+
** [[API17:JHtmlBehavior::combobox|JHtmlBehavior::combobox]]
** [[JElementList::fetchElement/11.1|JElementList::fetchElement]]
+
** [[API17:JElementList::fetchElement|JElementList::fetchElement]]
** [[JHtmlBehavior::formvalidation/11.1|JHtmlBehavior::formvalidation]]
+
** [[API17:JHtmlBehavior::formvalidation|JHtmlBehavior::formvalidation]]
** [[JHtmlBehavior::framework/11.1|JHtmlBehavior::framework]]
+
** [[API17:JHtmlBehavior::framework|JHtmlBehavior::framework]]
** [[JHtmlList::genericordering/11.1|JHtmlList::genericordering]]
+
** [[API17:JHtmlList::genericordering|JHtmlList::genericordering]]
** [[JFormFieldTimezone::getGroups/11.1|JFormFieldTimezone::getGroups]]
+
** [[API17:JFormFieldTimezone::getGroups|JFormFieldTimezone::getGroups]]
** [[JFormFieldTemplateStyle::getGroups/11.1|JFormFieldTemplateStyle::getGroups]]
+
** [[API17:JFormFieldTemplateStyle::getGroups|JFormFieldTemplateStyle::getGroups]]
** [[JFormFieldMenuItem::getGroups/11.1|JFormFieldMenuItem::getGroups]]
+
** [[API17:JFormFieldMenuItem::getGroups|JFormFieldMenuItem::getGroups]]
** [[JFormFieldGroupedList::getGroups/11.1|JFormFieldGroupedList::getGroups]]
+
** [[API17:JFormFieldGroupedList::getGroups|JFormFieldGroupedList::getGroups]]
** [[JFormFieldModuleLayout::getInput/11.1|JFormFieldModuleLayout::getInput]]
+
** [[API17:JFormFieldModuleLayout::getInput|JFormFieldModuleLayout::getInput]]
** [[JFormFieldMedia::getInput/11.1|JFormFieldMedia::getInput]]
+
** [[API17:JFormFieldMedia::getInput|JFormFieldMedia::getInput]]
** [[JFormFieldList::getInput/11.1|JFormFieldList::getInput]]
+
** [[API17:JFormFieldList::getInput|JFormFieldList::getInput]]
** [[JFormFieldGroupedList::getInput/11.1|JFormFieldGroupedList::getInput]]
+
** [[API17:JFormFieldGroupedList::getInput|JFormFieldGroupedList::getInput]]
** [[JFormFieldComponentLayout::getInput/11.1|JFormFieldComponentLayout::getInput]]
+
** [[API17:JFormFieldComponentLayout::getInput|JFormFieldComponentLayout::getInput]]
** [[JFormFieldCombo::getInput/11.1|JFormFieldCombo::getInput]]
+
** [[API17:JFormFieldCombo::getInput|JFormFieldCombo::getInput]]
** [[JFormFieldCalendar::getInput/11.1|JFormFieldCalendar::getInput]]
+
** [[API17:JFormFieldCalendar::getInput|JFormFieldCalendar::getInput]]
** [[JFormFieldAccessLevel::getInput/11.1|JFormFieldAccessLevel::getInput]]
+
** [[API17:JFormFieldAccessLevel::getInput|JFormFieldAccessLevel::getInput]]
** [[JFormFieldUsergroup::getInput/11.1|JFormFieldUsergroup::getInput]]
+
** [[API17:JFormFieldUsergroup::getInput|JFormFieldUsergroup::getInput]]
** [[JFormFieldUser::getInput/11.1|JFormFieldUser::getInput]]
+
** [[API17:JFormFieldUser::getInput|JFormFieldUser::getInput]]
** [[JFormFieldRules::getInput/11.1|JFormFieldRules::getInput]]
+
** [[API17:JFormFieldRules::getInput|JFormFieldRules::getInput]]
** [[JPagination::getLimitBox/11.1|JPagination::getLimitBox]]
+
** [[API17:JPagination::getLimitBox|JPagination::getLimitBox]]
** [[JFormFieldSQL::getOptions/11.1|JFormFieldSQL::getOptions]]
+
** [[API17:JFormFieldSQL::getOptions|JFormFieldSQL::getOptions]]
** [[JFormFieldSessionHandler::getOptions/11.1|JFormFieldSessionHandler::getOptions]]
+
** [[API17:JFormFieldSessionHandler::getOptions|JFormFieldSessionHandler::getOptions]]
** [[JFormFieldRadio::getOptions/11.1|JFormFieldRadio::getOptions]]
+
** [[API17:JFormFieldRadio::getOptions|JFormFieldRadio::getOptions]]
** [[JFormFieldList::getOptions/11.1|JFormFieldList::getOptions]]
+
** [[API17:JFormFieldList::getOptions|JFormFieldList::getOptions]]
** [[JFormFieldInteger::getOptions/11.1|JFormFieldInteger::getOptions]]
+
** [[API17:JFormFieldInteger::getOptions|JFormFieldInteger::getOptions]]
** [[JFormFieldFolderList::getOptions/11.1|JFormFieldFolderList::getOptions]]
+
** [[API17:JFormFieldFolderList::getOptions|JFormFieldFolderList::getOptions]]
** [[JFormFieldFileList::getOptions/11.1|JFormFieldFileList::getOptions]]
+
** [[API17:JFormFieldFileList::getOptions|JFormFieldFileList::getOptions]]
** [[JFormFieldContentLanguage::getOptions/11.1|JFormFieldContentLanguage::getOptions]]
+
** [[API17:JFormFieldContentLanguage::getOptions|JFormFieldContentLanguage::getOptions]]
** [[JFormFieldCheckboxes::getOptions/11.1|JFormFieldCheckboxes::getOptions]]
+
** [[API17:JFormFieldCheckboxes::getOptions|JFormFieldCheckboxes::getOptions]]
** [[JFormFieldCacheHandler::getOptions/11.1|JFormFieldCacheHandler::getOptions]]
+
** [[API17:JFormFieldCacheHandler::getOptions|JFormFieldCacheHandler::getOptions]]
** [[JFormFieldCategory::getOptions/11.1|JFormFieldCategory::getOptions]]
+
** [[API17:JFormFieldCategory::getOptions|JFormFieldCategory::getOptions]]
** [[JFormFieldMenu::getOptions/11.1|JFormFieldMenu::getOptions]]
+
** [[API17:JFormFieldMenu::getOptions|JFormFieldMenu::getOptions]]
** [[JHtmlList::images/11.1|JHtmlList::images]]
+
** [[API17:JHtmlList::images|JHtmlList::images]]
** [[JHtmlSelect::integerlist/11.1|JHtmlSelect::integerlist]]
+
** [[API17:JHtmlSelect::integerlist|JHtmlSelect::integerlist]]
** [[JHtmlAccess::level/11.1|JHtmlAccess::level]]
+
** [[API17:JHtmlAccess::level|JHtmlAccess::level]]
** [[JHtmlMenu::linkoptions/11.1|JHtmlMenu::linkoptions]]
+
** [[API17:JHtmlMenu::linkoptions|JHtmlMenu::linkoptions]]
** [[JHtmlMenu::menuitemlist/11.1|JHtmlMenu::menuitemlist]]
+
** [[API17:JHtmlMenu::menuitemlist|JHtmlMenu::menuitemlist]]
** [[JHtmlMenu::menuitems/11.1|JHtmlMenu::menuitems]]
+
** [[API17:JHtmlMenu::menuitems|JHtmlMenu::menuitems]]
** [[JHtmlBehavior::modal/11.1|JHtmlBehavior::modal]]
+
** [[API17:JHtmlBehavior::modal|JHtmlBehavior::modal]]
** [[JHtmlCategory::options/11.1|JHtmlCategory::options]]
+
** [[API17:JHtmlCategory::options|JHtmlCategory::options]]
** [[JPagination::orderDownIcon/11.1|JPagination::orderDownIcon]]
+
** [[API17:JPagination::orderDownIcon|JPagination::orderDownIcon]]
** [[JHtmlList::ordering/11.1|JHtmlList::ordering]]
+
** [[API17:JHtmlList::ordering|JHtmlList::ordering]]
** [[JHtmlMenu::ordering/11.1|JHtmlMenu::ordering]]
+
** [[API17:JHtmlMenu::ordering|JHtmlMenu::ordering]]
** [[JPagination::orderUpIcon/11.1|JPagination::orderUpIcon]]
+
** [[API17:JPagination::orderUpIcon|JPagination::orderUpIcon]]
** [[JHtmlList::positions/11.1|JHtmlList::positions]]
+
** [[API17:JHtmlList::positions|JHtmlList::positions]]
** [[script/11.1|script]]
+
** [[script|script]]
** [[JHtmlBehavior::switcher/11.1|JHtmlBehavior::switcher]]
+
** [[API17:JHtmlBehavior::switcher|JHtmlBehavior::switcher]]
** [[JHtmlBehavior::uploader/11.1|JHtmlBehavior::uploader]]
+
** [[API17:JHtmlBehavior::uploader|JHtmlBehavior::uploader]]
** [[JHtmlAccess::usergroup/11.1|JHtmlAccess::usergroup]]
+
** [[API17:JHtmlAccess::usergroup|JHtmlAccess::usergroup]]
** [[JHtmlList::users/11.1|JHtmlList::users]]
+
** [[API17:JHtmlList::users|JHtmlList::users]]
  
 
===See also===
 
===See also===
 
* {{JVer|11.1}} '''JHtml::_ source code''' on [[jplatform:html/html.php#cl-69|BitBucket]]
 
* {{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}} Class [[API17:JHtml|JHtml]]
* {{JVer|11.1}} Subpackage [[Subpackage_Html/11.1|Html]]
+
* {{JVer|11.1}} Subpackage [[API17:Subpackage_Html|Html]]
* [[JHtml::_|Other versions of JHtml::_]]
+
* [[API17:JHtml::_|Other versions of JHtml::_]]
{{SeeAlso:JHtml::_}}
+
 
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[</nowiki>[[SeeAlso:JHtml::_|Edit See Also]]<nowiki>]</nowiki>
 
</span>
 
 
===User contributed notes===
 
===User contributed notes===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
noresultsheader=\n
 
noresultsheader=\n
 
category=JHtml::_
 
category=JHtml::_
category=CodeExample
+
namespace=CodeExample
 
category=MethodExample
 
category=MethodExample
 
include=*
 
include=*
Line 139: Line 135:
 
format= ,,,
 
format= ,,,
 
</dpl>
 
</dpl>
<noinclude>[[Category:JHtml]][[Category:JHtml::_]]</noinclude>
+
<noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude>

Latest revision as of 22:10, 24 March 2017

The "API17" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Joomla 11.1 JHtml::_[edit]

Description[edit]

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[edit]

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[edit]

Any additinal parameters passed to JHtml::_() will be passed as parameters themselves to the resolved method.

Caching[edit]

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.


public static function _ ($key)
Parameter Type Default Description
$key

See also[edit]


User contributed notes[edit]

Code Examples[edit]