function icon_field_field_formatter_view in Icon API 7
Implements hook_field_formatter_view().
File
- modules/
icon_field/ icon_field.module, line 127 - icon_field.module Provides a field for attaching an icon to a fieldable entity.
Code
function icon_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$elements = array();
foreach ($items as $delta => $item) {
$item += array(
'wrapper' => '',
'wrapper_class' => '',
);
if ($display['settings']['link_to_content']) {
$uri = entity_uri($entity_type, $entity);
$options = array(
'html' => TRUE,
'attributes' => array(),
);
if (isset($uri['options']) and !empty($uri['options'])) {
$options = array_merge($uri['options'], $options);
}
$elements[$delta] = array(
'#theme' => 'link',
'#path' => $uri['path'],
'#text' => theme('icon', $item),
'#options' => $options,
);
}
else {
$elements[$delta] = array(
'#theme' => 'icon',
'#bundle' => $item['bundle'],
'#icon' => $item['icon'],
'#wrapper' => $item['wrapper'],
'#wrapper_class' => $item['wrapper_class'],
);
}
}
return $elements;
}