In version 1.1 hook_field_formatter_view changed from
/**
* Implements hook_field_formatter_view().
*/
function link_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#markup' => theme('link_formatter_'. $display['type'], array('element' => $item, 'field' => $instance)),
);
}
return $elements;
}
to
/**
* Implements hook_field_formatter_view().
*/
function link_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$elements = array();
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#theme' => 'link_formatter_' . $display['type'],
'#element' => $item,
'#field' => $instance,
'#display' => $display,
);
}
return $elements;
}
In the view result this causes recursion when rendering a field. In the view results ($view->result) I get :
stdClass Object
(
[nid] => 123456
[field_my_link] => Array
(
[0] => Array
(
[rendered] => Array
(
[#theme] => link_formatter_link_plain
[#element] => Array(/* snip */)
[#field] => Array(/* snip */)
[#display] => Array
(
[type] => link_plain
[settings] => Array
(
[skip_safe] => 0
[skip_empty_values] => 0
)
[label] => hidden
[views_view] => view Object
(
[result] => Array(
/* Same view results again, recursion */
)
....
Anyone that can confirm this?
The only the function that uses the display info is theme_link_formatter_link_domain ($vars['display']['settings']['strip_www']). Instead of passing along the the entire display variable we can simply set a strip_www variable.
Comments
Comment #1
interx commentedPatch added. I kept the existing structure of ['#display']['settings']['strip_www'] to make sure any overridden theme_link_formatter_link_domain() still works.
In views with a lot of link fields this gives a big performance benefit.
Comment #2
interx commentedComment #3
pifagor commentedlook good for me
Comment #5
pifagor commented