HTMLHelper
Utility class for all HTML drawing classes
| since |
1.5 |
|---|---|
| package |
Joomla CMS |
Methods
_
Class loader method
_( key, methodArgs) :
Additional arguments may be supplied and are passed to the sub-class. Additional include paths are also able to be specified for third-party use
| since |
1.5 |
|---|---|
| throws |
|
Arguments
- key
stringThe name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers.- methodArgs
mixedThe arguments to pass forward to the method being called
Response
mixedResult of HTMLHelper::call($function, $args)
addFileToBuffer
Method that searches if file exists in given path and returns the relative path. If a minified version exists it will be preferred.
addFileToBuffer( path = '', ext = '', debugMode = false) :
| since |
4.0.0 |
|---|
Arguments
- path
stringThe actual path of the file- ext
stringThe extension of the file- debugMode
boolSignifies if debug is enabled
Response
stringThe relative path of the file
addIncludePath
Add a directory where HTMLHelper should search for helpers. You may either pass a string or an array of directories.
addIncludePath( path = '') : mixed||string|int
| since |
1.5 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 Use the service registry instead |
Arguments
- path
stringA path to search.
Response
array<string|int, mixed>An array with directory elements
calendar
Displays a calendar control field
calendar( value, name, id, format = '%Y-%m-%d', attribs = []) :
| since |
1.5 |
|---|
Arguments
- value
stringThe date value- name
stringThe name of the text field- id
stringThe id of the text field- format
stringThe date format- attribs
mixedAdditional HTML attributes The array can have the following keys: readonly Sets the readonly parameter for the input tag disabled Sets the disabled parameter for the input tag autofocus Sets the autofocus parameter for the input tag autocomplete Sets the autocomplete parameter for the input tag filter Sets the filter for the input tag
Response
stringHTML markup for a calendar field
call
Function caller method
call( Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768 |Array function, mixed||string|int args) :
| link | |
|---|---|
| since |
1.6 |
| throws |
|
Arguments
- function
callableFunction or method to call- args
array<string|int, mixed>Arguments to be passed to function
Response
mixedFunction result or false on error.
checkFileOrder
Method that takes two paths and checks if the files exist with different order
checkFileOrder( first, second) :
| since |
4.0.0 |
|---|
Arguments
- first
stringthe path of the minified file- second
stringthe path of the non minified file
Response
string
cleanImageURL
Gets a URL, cleans the Joomla specific params and returns an object
cleanImageURL( url) :
| example |
{ url: 'string', attributes: [ width: integer, height: integer, ] } |
|---|---|
| since |
4.0.0 |
Arguments
- url
stringThe relative or absolute URL to use for the src attribute.
Response
object
convertToRelativePath
Method that takes a file path and converts it to a relative path
convertToRelativePath( path) :
| since |
4.0.0 |
|---|
Arguments
- path
stringThe actual path of the file
Response
stringThe relative path of the file
date
Returns formatted date according to a given format and time zone.
date( input = 'now', format = null, tz = true, gregorian = false) :
| see | strftime |
|---|---|
| since |
1.5 |
Arguments
- input
stringString in a format accepted by date(), defaults to "now".- format
stringThe date format specification string (see {@link PHP_MANUAL#date}).- tz
mixedTime zone to be used for the date. Special cases: boolean true for user setting, boolean false for server setting.- gregorian
boolTrue to use Gregorian calendar.
Response
stringA date translated by the given format and time zone.
extract
Method to extract a key
extract( key) : mixed||string|int
| since |
1.6 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 Use the service registry instead HTMLHelper::getServiceRegistry()->getService($file); |
Arguments
- key
stringThe name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers.
Response
array<string|int, mixed>Contains lowercase key, prefix, file, function.
getServiceRegistry
Retrieves the service registry.
getServiceRegistry() : \Joomla\CMS\HTML\Registry
iframe
Write a <iframe> element
iframe( url, name, array|string attribs = null, noFrames = '') :
| since |
1.5 |
|---|
Arguments
- url
stringThe relative URL to use for the src attribute.- name
stringThe target attribute to use.- attribs
array<string|int, mixed>|stringAttributes to be added to the<iframe>element- noFrames
stringThe message to display if the iframe tag is not supported.
Response
string
image
Write a <img> element
image( file, alt, array|string attribs = null, relative = false, returnPath) : string|null
| since |
1.5 |
|---|
Arguments
- file
stringThe relative or absolute URL to use for the src attribute.- alt
stringThe alt text.- attribs
array<string|int, mixed>|stringAttributes to be added to the<img>element- relative
boolFlag if the path to the file is relative to the /media folder (and searches in template).- returnPath
intDefines the return value for the method: -1: Returns a<img>tag without looking for relative files 0: Returns a<img>tag while searching for relative files 1: Returns the file path to the image while searching for relative files
Response
string|nullHTML markup for the image, relative path to the image, or null if path is to be returned but image is not found
includeRelativeFiles
Compute the files to be included
includeRelativeFiles( folder, file, relative, detectBrowser, detectDebug) : mixed||string|int
| see | Browser |
|---|---|
| since |
1.6 |
Arguments
- folder
stringFolder name to search in (i.e. images, css, js).- file
stringPath to file.- relative
boolFlag if the path to the file is relative to the /media folder (and searches in template).- detectBrowser
boolFlag if the browser should be detected to include specific browser files.- detectDebug
boolFlag if debug mode is enabled to include uncompressed files if debug is on.
Response
array<string|int, mixed>files to be included.
isRegistered
Test if the key is registered.
isRegistered( key) :
| since |
1.6 |
|---|
Arguments
- key
stringThe name of the key
Response
boolTrue if the key is registered.
link
Write a <a> element
link( url, text, array|string attribs = null) :
| since |
1.5 |
|---|
Arguments
- url
stringThe relative URL to use for the href attribute- text
stringThe target attribute to use- attribs
array<string|int, mixed>|stringAttributes to be added to the<a>element
Response
string
register
Registers a function to be called with a specific key
register( key, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768 |Array function) :
| since |
1.6 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 Use the service registry instead HTMLHelper::getServiceRegistry()->register($key, $function); |
Arguments
- key
stringThe name of the key- function
callableFunction or method
Response
boolTrue if the function is callable
script
Write a <script> element to load a JavaScript file
script( file, mixed||string|int options = [], mixed||string|int attribs = []) : array|string|null
| see | HTMLHelper::stylesheet() |
|---|---|
| since |
1.5 |
Arguments
- file
stringPath to file.- options
array<string|int, mixed>Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
array<string|int, mixed>Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
array<string|int, mixed>|string|nullNothing if $returnPath is false, null, path or array of path if specific JavaScript browser files were detected
setFormatOptions
Set format related options.
setFormatOptions(mixed||string|int options) :
Updates the formatOptions array with all valid values in the passed array.
| see | HTMLHelper::$formatOptions |
|---|---|
| since |
1.5 |
Arguments
- options
array<string|int, mixed>Option key/value pairs.
Response
void
strftimeFormatToDateFormat
Convert most popular strftime format to php date format as strftime is deprecated and we have to be able to provide same backward compatibility with existing format strings.
strftimeFormatToDateFormat(strftimeformat) :
stylesheet
Write a <link> element to load a CSS file
stylesheet( file, mixed||string|int options = [], mixed||string|int attribs = []) : array|string|null
| see | Browser |
|---|---|
| since |
1.5 |
Arguments
- file
stringPath to file- options
array<string|int, mixed>Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
array<string|int, mixed>Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
array<string|int, mixed>|string|nullnothing if $returnPath is false, null, path or array of path if specific CSS browser files were detected
tooltip
Creates a tooltip with an image as button
tooltip( tooltip, title = '', image = 'tooltip.png', text = '', href = '', alt = 'Tooltip', class = 'hasTooltip') :
| since |
1.5 |
|---|
Arguments
- tooltip
stringThe tip string.- title
mixedThe title of the tooltip or an associative array with keys contained in {'title','image','text','href','alt'} and values corresponding to parameters of the same name.- image
stringThe image for the tip, if no text is provided.- text
stringThe text for the tip.- href
stringA URL that will be used to create the link.- alt
stringThe alt attribute for img tag.- class
stringCSS class for the tool tip.
Response
string
tooltipText
Converts a double colon separated string or 2 separate strings to a string ready for bootstrap tooltips
tooltipText( title = '', content = '', translate = true, escape = true) :
| since |
3.1.2 |
|---|
Arguments
- title
stringThe title of the tooltip (or combined '::' separated string).- content
stringThe content to tooltip.- translate
boolIf true will pass texts through Text.- escape
boolIf true will pass texts through htmlspecialchars.
Response
stringThe tooltip string
unregister
Removes a key for a method from registry.
unregister( key) :
| since |
1.6 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 Use the service registry instead |
Arguments
- key
stringThe name of the key
Response
boolTrue if a set key is unset
Properties
formatOptions
Option values related to the generation of HTML output. Recognized options are: fmtDepth, integer. The current indent depth.
fmtEol, string. The end of line string, default is linefeed. fmtIndent, string. The string to use for indentation, default is tab.
| since |
1.5 |
|---|
Type(s)
array<string|int, mixed>
includePaths
An array to hold included paths
| since |
1.5 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 |
Type(s)
array<string|int, string>
registry
An array to hold method references
| since |
1.6 |
|---|---|
| deprecated |
4.0 will be removed in 6.0 |
Type(s)
array<string|int, callable>
serviceRegistry
The service registry for custom and overridden JHtml helpers