function og_field_formatter_view in Organic groups 7
Implements hook_field_formatter_view().
1 string reference to 'og_field_formatter_view'
- og_invalidate_cache in ./
og.module - Invalidate cache.
File
- ./
og.field.inc, line 50 - Field module functionality for the Organic groups module.
Code
function og_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
if ($field['field_name'] == OG_AUDIENCE_FIELD && !empty($items[0])) {
foreach ($items as $delta => $item) {
if ($group = og_get_group('group', $item['gid'])) {
if ($group
->access()) {
$label = og_label($group->gid);
$entity = entity_load($group->entity_type, array(
$group->etid,
));
$entity = current($entity);
// Get the entity type of the group entity.
$uri = entity_uri($group->entity_type, $entity);
$element[$delta] = array(
'#type' => 'link',
'#title' => $label,
'#href' => $uri['path'],
'#options' => array(
'html' => TRUE,
),
);
}
else {
// No need to show private groups several times, so remember if it was
// already added.
$added =& drupal_static(__FUNCTION__, FALSE);
if (!$added) {
$added = TRUE;
$element[$delta] = array(
'#markup' => '- ' . t('Private group') . ' -',
);
}
}
}
}
}
return $element;
}