On this page
function taxonomy_implode_tags
taxonomy_implode_tags($tags, $vid = NULL)
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 428
- Enables the organization of content into categories.
Code
function taxonomy_implode_tags($tags, $vid = NULL) {
$typed_tags = array();
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);
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!taxonomy!taxonomy.module/function/taxonomy_implode_tags/8.1.x