function textformatter_taxonomy_field_create_list in Text list formatter 8.2
Same name and namespace in other branches
- 7 textformatter.module \textformatter_taxonomy_field_create_list()
Create list for taxonomy reference fields.
1 string reference to 'textformatter_taxonomy_field_create_list'
File
- ./
textformatter.module, line 129 - Provide a field formatter to render values as HTML or comma-separated lists.
Code
function textformatter_taxonomy_field_create_list($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$list_items = $tids = array();
// Get an array of tids only.
foreach ($items as $item) {
$tids[] = $item['tid'];
}
$terms = taxonomy_term_load_multiple($tids);
foreach ($items as $delta => $item) {
// Check the term for this item has actually been loaded.
// @see http://drupal.org/node/1281114
if (empty($terms[$item['tid']])) {
continue;
}
// Use the item name if autocreating, as there won't be a term object yet.
$term_name = $item['tid'] === 'autocreate' ? $item['name'] : $terms[$item['tid']]->name;
// Check if we should display as term links or not.
if ($settings['term_plain'] || $item['tid'] === 'autocreate') {
$list_items[$delta] = check_plain($term_name);
}
else {
$uri = $terms[$item['tid']]
->uri();
$list_items[$delta] = l($term_name, $uri['path']);
}
}
return $list_items;
}