Back to Joomla project (class list)

Class StringHelper - list of methods

HTML helper class for rendering manipulated strings.
Package: Joomla\CMS\HTML\Helpers
Copyright: (C) 2010 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/HTML/Helpers/StringHelper.php
Project: Joomla

Method Summary

public static string
(mixed $text, mixed $length = 0, mixed $noSplit = true, mixed $allowHtml = true)

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.
Parameters
  • string $text The text to truncate.
  • int $length The maximum length of the text.
  • bool $noSplit Don't split a word if that is where the cutoff occurs (default: true).
  • bool $allowHtml Allow HTML tags in the output, and close any open tags (default: true).
Returns
  • string The truncated text.
Since
  • 1.6
Show source code of this method: truncate Source Code

public static string
(mixed $html, mixed $maxLength = 0, mixed $noSplit = true)

Method to extend the truncate method to more complex situations
Parameters
  • string $html The content of the introtext to be truncated
  • int $maxLength The maximum number of characters to render
  • bool $noSplit Don't split a word if that is where the cutoff occurs (default: true).
Returns
  • string The truncated string. If the string is truncated an ellipsis (...) will be appended.
Since
  • 3.1
-
  • 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.
Show source code of this method: truncateComplex Source Code

public static string
(mixed $text, mixed $length = 50, mixed $intro = 30)

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.
Parameters
  • string $text The text to abridge.
  • int $length The maximum length of the text (default is 50).
  • int $intro The maximum length of the intro text (default is 30).
Returns
  • string The abridged text.
Since
  • 1.6
Show source code of this method: abridge Source Code

Tags Summary

Since
1.6