function taxonomy_implode_tags
Same name in other branches
- 7.x modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
- 9 core/modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
Implodes a list of tags of a certain vocabulary into a string.
See also
\Drupal\Component\Utility\Tags::explode()
File
-
core/
modules/ taxonomy/ taxonomy.module, line 469
Code
function taxonomy_implode_tags($tags, $vid = NULL) {
$typed_tags = [];
foreach ($tags as $tag) {
// Extract terms belonging to the vocabulary in question.
if (!isset($vid) || $tag->bundle() == $vid) {
// Make sure we have a completed loaded taxonomy term.
if ($tag instanceof EntityInterface && ($label = $tag->label())) {
// Commas and quotes in tag names are special cases, so encode 'em.
$typed_tags[] = Tags::encode($label);
}
}
}
return implode(', ', $typed_tags);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.