GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
tedkulp (author)
Fri Mar 07 11:28:43 -0800 2008
commit  33bca6f98dfd0ef6901f6a2c8f0b725c6a288528
tree    151e1ce1c03b63a3fc94ffeec0b02c7ac7af0077
parent  19a6d7159da286ce9fa7169c953286461160a962
cmsmadesimple-2-0 / plugins / modifier.summarize.php
100644 33 lines (27 sloc) 0.985 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* Smarty plugin
* ----------------------------------------------------------------
* Type: modifier
* Name: summarize
* Purpose: returns desired amount of words from the full string
* ideal for article text, etc.
* Auther: MarkS, AKA Skram, mark@mark-s.net /
* http://dev.cmsmadesimple.org/users/marks/
* ----------------------------------------------------------------
**/
function smarty_cms_modifier_summarize($string,$numwords='5',$etc='...'){
 
//=Put each word (any character or group of characters seperated by a space) into the field's array
$stringarray = explode(" ",$string);
 
//=While loop to add int ($numwords) words to the summary string ($returnstring)
$i = 0;
while($i < $numwords){
    $returnstring .= " ".$stringarray[$i];
    $i++;
}
 
//If set, the suffix (by default "...") will now be added to the summary ($returnstring)
$returnstring .= "...";
 
//Return the summary!
return $returnstring;
    
}//end of function
?>