создание фильтра для друпал . пример

Сначала - как при создании любого модуля создайте в директории , выделенной для размещения модуля в составе движка стандартные
.info и .module файлы.
В .module , для реализации фильтра нашим модулем следует реализовать хук (имя выбирайте самостоятельно) =

/** 
* Implement hook_filter_info(). 
*/ 
function creativejuice_filter_info() { 
  $filters = array(); 
  $filters['creativejuice'] = array( 
    'title' => t('Creative Juice filter'), 
    'description' => t('Enables users to insert random sentences into their post'), 
    'process callback' => '_creativejuice_filter_process', 
    'tips callback' => '_creativejuice_filter_tips', 
  ); 
  return $filters; 
} 

при этом фильтрация непосредственно будет выполняться подобной функцией =

/** 
 * Creativejuice filter process callback 
 * 
 * The actual filtering is performed here. The supplied text should be 
 * returned, once any necessary substitutions have taken place. 
 */ 
function _creativejuice_filter_process($text, $filter, $format) { 
  while (strpos($text, '[juice!]') !== FALSE) { 
    $sentence = creativejuice_sentence();  
    $text = preg_replace('&\[juice!\]&', $sentence, $text, 1); 
  } 
  return $text; 
}