Browse Source

Improve teaser

pull/189/head
Danang Probo Sayekti 10 years ago
parent
commit
2107ef20a0
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      system/includes/functions.php

+ 8
- 0
system/includes/functions.php View File

@ -933,6 +933,9 @@ function get_description($string, $char = null)
{ {
if(empty($char)) { if(empty($char)) {
$char = config('description.char'); $char = config('description.char');
if(empty($char)) {
$char = 150;
}
} }
$string = remove_accent($string); $string = remove_accent($string);
$string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($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)) { if(empty($char)) {
$char = config('teaser.char'); $char = config('teaser.char');
if(empty($char)) {
$char = 200;
}
} }
if ($teaserType === 'full') { if ($teaserType === 'full') {
echo $text; echo $text;
} elseif (strlen(strip_tags($text)) < $char) {
echo preg_replace('/\s\s+/', ' ', strip_tags($text));
} else { } else {
$string = preg_replace('/\s\s+/', ' ', strip_tags($text)); $string = preg_replace('/\s\s+/', ' ', strip_tags($text));
$string = substr($string, 0, $char); $string = substr($string, 0, $char);


Loading…
Cancel
Save