function social_comments_field_formatter_view in Open Social 7
Implements hook_field_formatter_view().
File
- ./
social_comments.module, line 262
Code
function social_comments_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$elements = array();
$settings = $display['settings'];
if ($display['type'] == 'social_comments_google' || $display['type'] == 'social_comments_facebook' || $display['type'] == 'social_comments_twitter') {
$type = str_replace('social_comments_', '', $display['type']);
$formatter = 'Social' . drupal_ucfirst($type) . 'Formatter';
foreach ($items as $delta => $item) {
$count = $settings['count'];
$bundle = $instance['bundle'];
$comments = new $formatter();
$comments = $comments
->getData($item['url'], $count);
if ($comments) {
$elements[$delta] = array(
'#theme' => 'social_comments_items',
'#comments' => $comments,
'#bundle' => $bundle,
'#entity_type' => $entity_type,
'#type' => $type,
);
}
}
}
return $elements;
}