Joomla CMS  3.8.5 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.8.5 et du framework Joomla Platform intégré
Référence de la classe JHtmlString

Fonctions membres publiques statiques

static truncate ($text, $length=0, $noSplit=true, $allowHtml=true)
 
static truncateComplex ($html, $maxLength=0, $noSplit=true)
 
static abridge ($text, $length=50, $intro=30)
 

Description détaillée

HTML helper class for rendering manipulated strings.

Depuis
1.6

Documentation des fonctions membres

◆ abridge()

static abridge (   $text,
  $length = 50,
  $intro = 30 
)
static

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.

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.

Paramètres
string$textThe text to abridge.
integer$lengthThe maximum length of the text (default is 50).
integer$introThe maximum length of the intro text (default is 30).
Renvoie
string The abridged text.
Depuis
1.6

Références $text.

◆ truncate()

static truncate (   $text,
  $length = 0,
  $noSplit = true,
  $allowHtml = true 
)
static

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.

Paramètres
string$textThe text to truncate.
integer$lengthThe maximum length of the text.
boolean$noSplitDon't split a word if that is where the cutoff occurs (default: true).
boolean$allowHtmlAllow HTML tags in the output, and close any open tags (default: true).
Renvoie
string The truncated text.
Depuis
1.6

Références $i, $offset, $text, $tmp, et ENT_QUOTES.

◆ truncateComplex()

static truncateComplex (   $html,
  $maxLength = 0,
  $noSplit = true 
)
static

Method to extend the truncate method to more complex situations

The goal is to get the proper length plain text string with as much of the html intact as possible with all tags properly closed.

Paramètres
string$htmlThe content of the introtext to be truncated
integer$maxLengthThe maximum number of characters to render
boolean$noSplitDon't split a word if that is where the cutoff occurs (default: true).
Renvoie
string The truncated string. If the string is truncated an ellipsis (...) will be appended.
Note
If a maximum length of 3 or less is selected and the text has more than that number of characters an ellipsis will be displayed. This method will not create valid HTML from malformed HTML.
Depuis
3.1

Références $html.


La documentation de cette classe a été générée à partir du fichier suivant :