cergey-obr
3/25/2015 - 9:41 AM

Обрезка текста страницы

Обрезка текста страницы

public function cutText($pageId, $fieldName, $num = '20') {
	$text = umiHierarchy::getInstance()->getElement($pageId)->getValue($fieldName);
	$text = strip_tags($text);
	$words = explode(' ', $text);
	$output = array_slice($words, 0, $num);
	if(sizeof($words) > $num) $text = implode(' ', $output).'...';
	else $text = $text;
	return $text;
}