15 Sep 2013 18:21:14

Drupal. Text filter example

Text processor filter creation code.

To provide drupal 7 text filter you need implement only one hook & callback to process input data:

/**
 * Implements hook_filter_info().
 */
function mymodulename_filter_info() {
  $filters['text_node_wrapper'] = array(
    'title'            => t('Text Filter'),
    'description'      => t('Change input field data'),
    'process callback' => 'mymodulename_text_wrapper',
  );
  return $filters;
}
There is callback example provides input data alter by retrieving argument.
/**
 * Wrapp text nodes.
 */
function mymodulename_text_wrapper($text) {
  $text = '<span>' . $text . '</span>';

  return $text;
}

That is all!

Comments:

add comment

Image CAPTCHA