From 2107ef20a0feca042d68f3008df850e1524b1780 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Wed, 22 Jul 2015 13:54:37 +0700 Subject: [PATCH] Improve teaser --- system/includes/functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system/includes/functions.php b/system/includes/functions.php index 4c85d43..8a067ac 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -933,6 +933,9 @@ function get_description($string, $char = null) { if(empty($char)) { $char = config('description.char'); + if(empty($char)) { + $char = 150; + } } $string = remove_accent($string); $string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($string)); @@ -948,10 +951,15 @@ function get_teaser($text, $char = null) if(empty($char)) { $char = config('teaser.char'); + if(empty($char)) { + $char = 200; + } } if ($teaserType === 'full') { echo $text; + } elseif (strlen(strip_tags($text)) < $char) { + echo preg_replace('/\s\s+/', ' ', strip_tags($text)); } else { $string = preg_replace('/\s\s+/', ' ', strip_tags($text)); $string = substr($string, 0, $char);