You are here

function content_taxonomy_autocomplete_merge_tags in Content Taxonomy 6

Same name and namespace in other branches
  1. 5 content_taxonomy_autocomplete.module \content_taxonomy_autocomplete_merge_tags()
  2. 6.2 content_taxonomy_autocomplete.module \content_taxonomy_autocomplete_merge_tags()

Helper function to merge the tags, to prefill the fields when editing a node.

1 call to content_taxonomy_autocomplete_merge_tags()
content_taxonomy_autocomplete_value in ./content_taxonomy_autocomplete.module
Value for a content taxonomy autocomplete field

File

./content_taxonomy_autocomplete.module, line 413
Defines a widget type for content_taxonomy with autocomplete

Code

function content_taxonomy_autocomplete_merge_tags($terms, $vid) {
  $typed_terms = array();
  if (!empty($terms)) {
    foreach ($terms as $term) {

      // Commas and quotes in terms are special cases, so encode 'em.
      $name = $term->name;
      if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
        $name = '"' . preg_replace('/"/', '""', $name) . '"';
      }
      $typed_terms[] = $name;
    }
  }
  return implode(', ', $typed_terms);
}