function linkicon_field_formatter_prepare_view in Link Icon 7
Implements hook_field_formatter_prepare_view().
File
- ./
linkicon.module, line 69 - A link field formatter to create icon classes based on predefined titles.
Code
function linkicon_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
// Unlike D8, we need to loop first to reach our settings.
foreach ($items as $entity_id => $entity_items) {
if (isset($instances[$entity_id]['settings']['title']) && $instances[$entity_id]['settings']['title'] == 'predefined' && isset($instances[$entity_id]['settings']['title_predefined']) && $instances[$entity_id]['settings']['title_predefined']) {
$title_predefined = linkicon_extract_allowed_values($instances[$entity_id]['settings']['title_predefined']);
$title_tooltip = linkicon_extract_allowed_values($instances[$entity_id]['settings']['title_predefined'], TRUE);
foreach ($entity_items as $delta => $value) {
$items[$entity_id][$delta]['display_title'] = $title_predefined[$value['title']];
if (isset($title_tooltip[$value['title']])) {
$items[$entity_id][$delta]['tooltip'] = $title_tooltip[$value['title']];
}
}
}
}
}