HTMLHelper
Utility class for all HTML drawing classes
since |
1.5 |
---|---|
package |
Joomla CMS |
Methods
_
Class loader method
_(string key, mixed methodArgs) : mixed
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
string
The name of helper method to load, (prefix).(class).function prefix and class are optional and can be used to load custom html helpers.- methodArgs
mixed
The arguments to pass forward to the method being called
Response
mixed
Result 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(string path = '', string ext = '', bool debugMode = false) : string
since |
4.0.0 |
---|
Arguments
- path
string
The actual path of the file- ext
string
The extension of the file- debugMode
bool
Signifies if debug is enabled
Response
string
The 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(string path = '') : array
since |
1.5 |
---|---|
deprecated |
5.0 Use the service registry instead |
Arguments
- path
string
A path to search.
Response
array
An array with directory elements
calendar
Displays a calendar control field
calendar(string value, string name, string id, string format = '%Y-%m-%d', mixed attribs = array()) : string
since |
1.5 |
---|
Arguments
- value
string
The date value- name
string
The name of the text field- id
string
The id of the text field- format
string
The date format- attribs
mixed
Additional 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
string
HTML markup for a calendar field
call
Function caller method
call(callable function, array args) : mixed
link | |
---|---|
since |
1.6 |
throws |
|
Arguments
- function
callable
Function or method to call- args
array
Arguments to be passed to function
Response
mixed
Function result or false on error.
checkFileOrder
Method that takes two paths and checks if the files exist with different order
checkFileOrder(string first, string second) : string
since |
4.0.0 |
---|
Arguments
- first
string
the path of the minified file- second
string
the path of the non minified file
Response
string
cleanImageURL
Gets a URL, cleans the Joomla specific params and returns an object
cleanImageURL(string url) : object
example |
{ url: 'string', attributes: [ width: integer, height: integer, ] } |
---|---|
since |
4.0.0 |
Arguments
- url
string
The 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(string path) : string
since |
4.0.0 |
---|
Arguments
- path
string
The actual path of the file
Response
string
The relative path of the file
date
Returns formatted date according to a given format and time zone.
date(string input = 'now', string format = null, mixed tz = true, bool gregorian = false) : string
see | \Joomla\CMS\HTML\strftime |
---|---|
since |
1.5 |
Arguments
- input
string
String in a format accepted by date(), defaults to "now".- format
string
The date format specification string (see {@link PHP_MANUAL#date}).- tz
mixed
Time zone to be used for the date. Special cases: boolean true for user setting, boolean false for server setting.- gregorian
bool
True to use Gregorian calendar.
Response
string
A date translated by the given format and time zone.
extract
Method to extract a key
extract(string key) : array
since |
1.6 |
---|---|
deprecated |
5.0 Use the service registry instead |
Arguments
- key
string
The 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
Contains lowercase key, prefix, file, function.
getServiceRegistry
Retrieves the service registry.
getServiceRegistry() : \Joomla\CMS\HTML\Registry
since |
4.0.0 |
---|
Response
\Joomla\CMS\HTML\Registry
iframe
Write a <iframe>
element
iframe(string url, string name, array|string attribs = null, string noFrames = '') : string
since |
1.5 |
---|
Arguments
- url
string
The relative URL to use for the src attribute.- name
string
The target attribute to use.- attribs
array|string
Attributes to be added to the<iframe>
element- noFrames
string
The message to display if the iframe tag is not supported.
Response
string
image
Write a <img>
element
image(string file, string alt, array|string attribs = null, bool relative = false, int returnPath) : string|null
since |
1.5 |
---|
Arguments
- file
string
The relative or absolute URL to use for the src attribute.- alt
string
The alt text.- attribs
array|string
Attributes to be added to the<img>
element- relative
bool
Flag if the path to the file is relative to the /media folder (and searches in template).- returnPath
int
Defines 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|null
HTML 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(string folder, string file, bool relative, bool detectBrowser, bool detectDebug) : array
see | Browser |
---|---|
since |
1.6 |
Arguments
- folder
string
Folder name to search in (i.e. images, css, js).- file
string
Path to file.- relative
bool
Flag if the path to the file is relative to the /media folder (and searches in template).- detectBrowser
bool
Flag if the browser should be detected to include specific browser files.- detectDebug
bool
Flag if debug mode is enabled to include uncompressed files if debug is on.
Response
array
files to be included.
isRegistered
Test if the key is registered.
isRegistered(string key) : bool
since |
1.6 |
---|
Arguments
- key
string
The name of the key
Response
bool
True if the key is registered.
link
Write a <a>
element
link(string url, string text, array|string attribs = null) : string
since |
1.5 |
---|
Arguments
- url
string
The relative URL to use for the href attribute- text
string
The target attribute to use- attribs
array|string
Attributes to be added to the<a>
element
Response
string
register
Registers a function to be called with a specific key
register(string key, callable function) : bool
since |
1.6 |
---|---|
deprecated |
5.0 Use the service registry instead |
Arguments
- key
string
The name of the key- function
callable
Function or method
Response
bool
True if the function is callable
script
Write a <script>
element to load a JavaScript file
script(string file, array options = array(), array attribs = array()) : array|string|null
see | HTMLHelper::stylesheet() |
---|---|
since |
1.5 |
Arguments
- file
string
Path to file.- options
array
Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
array
Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
array|string|null
Nothing if $returnPath is false, null, path or array of path if specific JavaScript browser files were detected
setFormatOptions
Set format related options.
setFormatOptions(array options) : void
Updates the formatOptions array with all valid values in the passed array.
see | HTMLHelper::$formatOptions |
---|---|
since |
1.5 |
Arguments
- options
array
Option key/value pairs.
stylesheet
Write a <link>
element to load a CSS file
stylesheet(string file, array options = array(), array attribs = array()) : array|string|null
see | Browser |
---|---|
since |
1.5 |
Arguments
- file
string
Path to file- options
array
Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
array
Array of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
array|string|null
nothing 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(string tooltip, mixed title = '', string image = 'tooltip.png', string text = '', string href = '', string alt = 'Tooltip', string class = 'hasTooltip') : string
since |
1.5 |
---|
Arguments
- tooltip
string
The tip string.- title
mixed
The 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
string
The image for the tip, if no text is provided.- text
string
The text for the tip.- href
string
A URL that will be used to create the link.- alt
string
The alt attribute for img tag.- class
string
CSS 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(string title = '', string content = '', bool translate = true, bool escape = true) : string
since |
3.1.2 |
---|
Arguments
- title
string
The title of the tooltip (or combined '::' separated string).- content
string
The content to tooltip.- translate
bool
If true will pass texts through Text.- escape
bool
If true will pass texts through htmlspecialchars.
Response
string
The tooltip string
unregister
Removes a key for a method from registry.
unregister(string key) : bool
since |
1.6 |
---|---|
deprecated |
5.0 Use the service registry instead |
Arguments
- key
string
The name of the key
Response
bool
True 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
includePaths
An array to hold included paths
registry
An array to hold method references
serviceRegistry
The service registry for custom and overridden JHtml helpers