Commit d4f8afdc authored by yched's avatar yched

#65133 / #152016 : 'full node' and 'teaser' formatters for nodereferences - thanks

 alex_b and ray007
parent 0f48a70e
......@@ -148,6 +148,14 @@ function nodereference_field_formatter_info() {
'label' => 'Title (no link)',
'field types' => array('nodereference'),
),
'full' => array(
'label' => 'Full node',
'field types' => array('nodereference'),
),
'teaser' => array(
'label' => 'Teaser',
'field types' => array('nodereference'),
),
);
}
......@@ -161,12 +169,25 @@ function nodereference_field_formatter($field, $item, $formatter, $node) {
return '';
}
if ($formatter == 'full' || $formatter == 'teaser') {
$referenced_node = node_load($item['nid']);
$referenced_node->referencing_node = $node;
$referenced_node->referencing_field = $field;
$titles[$item['nid']] = $referenced_node->title;
}
if (!isset($titles[$item['nid']])) {
$title = db_result(db_query("SELECT title FROM {node} WHERE nid=%d", $item['nid']));
$titles[$item['nid']] = $title ? $title : '';
}
switch ($formatter) {
case 'full':
return node_view($referenced_node, FALSE);
case 'teaser':
return node_view($referenced_node, TRUE);
case 'plain':
return $titles[$item['nid']];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment