You are here

function popup_nodereference_field_formatter_view in Popup 7

Same name and namespace in other branches
  1. 8 modules/popup_nodereference/popup_nodereference.module \popup_nodereference_field_formatter_view()

Implementation of hook_field_formatter_view

File

modules/popup_nodereference/popup_nodereference.module, line 87

Code

function popup_nodereference_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  module_load_include('inc', 'popup_ui', 'includes/popup_ui.admin');
  module_load_include('inc', 'popup', 'includes/popup.api');
  $element = array();
  $settings = $display['settings'];
  $formatters = _popup_ui_formatter_settings();
  $attributes = $formatters[$settings['popup_format']];
  if ($settings['popup_grouping'] && count($items)) {
    $nids = array();
    foreach ($items as $item) {
      if (isset($item['nid'])) {
        $nids[] = $item['nid'];
      }
    }
    $attributes['title'] = $instance['label'];
    $attributes['php'] = "module_load_include('inc', 'popup_nodereference', 'includes/popup_nodereference.util');" . "return _popup_nodereference_render_group(" . var_export($nids, TRUE) . ', ' . var_export($attributes, TRUE) . ');';
    $element[0] = array(
      '#markup' => popup($attributes),
    );
  }
  else {
    foreach ($items as $delta => $item) {
      if ($item['nid']) {
        $node_attribs = $attributes;
        $node_attribs['node'] = $item['nid'];
        $element[$delta] = array(
          '#markup' => popup($node_attribs),
        );
      }
    }
  }
  return $element;
}