Texte abschneiden - The Drupal Way
dereine — 26. März 2009 - 16:34
Hier ist eine Funktion fast 1zu1 aus Views kopiert
<?php
/**
* Trims a text to a certain length.
*
* @param string $value: The value which should be shortened.
* @param integer $length: The maximum length of the string.
*
* @return string Trimmed string.
*/
function drupal_render_trim_text($value, $length = 100, $points = TRUE) {
$value = strip_tags($value);
/**
* Trims a text to a certain length.
*
* @param string $value: The value which should be shortened.
* @param integer $length: The maximum length of the string.
*
* @return string Trimmed string.
*/
function drupal_render_trim_text($value, $length = 100, $points = TRUE) {
$value = strip_tags($value);
if (drupal_strlen($value) <= $length) {
return $value;
}
$value = drupal_substr($value, 0, $length);
if ($points) {
$value .= '...';
}
$value = _filter_htmlcorrector($value);
return $value;
}
?>
Mit Hilfe der Funktion kann man HTML abschneiden auf eine bestimmte Länge ohne das



Kommentar hinzufügen