function nodereferrer_field_load in NodeReferrer 7
implements hook_field_load().
File
- ./
nodereferrer.module, line 152 - Defines a field type for backlinking referencing nodes.
Code
function nodereferrer_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
$settings = $field['settings'];
// Get field settings.
$types = array_filter($settings['referrer_types']);
$fields = array_filter($settings['referrer_fields']);
$order = $settings['referrer_order'];
$translations = $settings['referrer_translations'];
foreach ($entities as $id => $entity) {
if ($instances[$id]['entity_type'] == 'node') {
$values = nodereferrer_referrers($id, $fields, $types, $translations, $order);
if (!empty($values)) {
$items[$id][0] = array(
'items' => $values,
'limit' => $settings['referrer_nodes_per_page'],
'element' => $settings['referrer_pager_element'],
'pager' => '',
);
}
}
}
/*
foreach ($items[$id] as $delta => $item) {
// Only process items with a cacheable format, the rest will be handled
// by formatters if needed.
if (empty($instances[$id]['settings']['prefix']) || filter_format_allowcache($item['format'])) {
$items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
if ($field['type'] == 'text_with_summary') {
$items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
}
}
}
}
$values = nodereferrer_referrers($node->nid, $fields, $types, $translations, $order);
// Pass referring node objects into CCK content_load() cache. 24/08/2006 sun
$items = array();
foreach ($values as $nid => $rnode) {
$items[] = $rnode;
}
if (count($items) == 0) {
return array($field['field_name'] => array());
}
$output = array(
'items' => $items,
'limit' => empty($field['referrer_nodes_per_page']) ? 0 : $field['referrer_nodes_per_page'],
'element' => empty($field['referrer_pager_element']) ? 0 : $field['referrer_pager_element'],
'pager' => '',
);
return array($field['field_name'] => array($output));*/
}