JHtmlString
HTML helper class for rendering manipulated strings.
package |
Joomla.Platform |
---|---|
subpackage |
HTML |
since |
11.1 |
Methods
abridge
Abridges text strings over the specified character limit. The behavior will insert an ellipsis into the text replacing a section of variable size to ensure the string does not exceed the defined maximum length. This method is UTF-8 safe.
abridge(string $text, integer $length = 50, integer $intro = 30) : string
For example, it transforms "Really long title" to "Really...title".
Note that this method does not scan for HTML tags so will potentially break them.
since |
11.1 |
---|
Arguments
- $text
string
The text to abridge.- $length
integer
The maximum length of the text (default is 50).- $intro
integer
The maximum length of the intro text (default is 30).
Response
string
The abridged text.
truncate
Truncates text blocks over the specified character limit and closes all open HTML tags. The method will optionally not truncate an individual word, it will find the first space that is within the limit and truncate at that point. This method is UTF-8 safe.
truncate(string $text, integer $length, boolean $noSplit = true, boolean $allowHtml = true) : string
since |
11.1 |
---|
Arguments
- $text
string
The text to truncate.- $length
integer
The maximum length of the text.- $noSplit
boolean
Don't split a word if that is where the cutoff occurs (default: true).- $allowHtml
boolean
Allow HTML tags in the output, and close any open tags (default: true).
Response
string
The truncated text.