[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/plugins/ -> modifier.summarize.php (source)

   1  <?php
   2  /**
   3   * Smarty plugin
   4   * ----------------------------------------------------------------
   5   * Type:     modifier
   6   * Name:     summarize
   7   * Purpose:  returns desired amount of words from the full string
   8   *        ideal for article text, etc.
   9   * Auther:   MarkS, AKA Skram, mark@mark-s.net /
  10   *        http://dev.cmsmadesimple.org/users/marks/
  11   * ----------------------------------------------------------------
  12   **/
  13  function smarty_cms_modifier_summarize($string,$numwords='5',$etc='...'){
  14  
  15  //=Put each word (any character or group of characters seperated by a space) into the field's array
  16  $stringarray = explode(" ",$string);
  17  
  18  //=While loop to add int ($numwords) words to the summary string ($returnstring)
  19  $i = 0;
  20  while($i < $numwords){
  21      $returnstring .= " ".$stringarray[$i];
  22      $i++;
  23  }
  24  
  25  //If set, the suffix (by default "...") will now be added to the summary ($returnstring)
  26  $returnstring .= "...";
  27  
  28  //Return the summary!
  29  return $returnstring;
  30      
  31  }//end of function
  32  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7