function contemplate_node_view in Content Templates (Contemplate) 7
Same name and namespace in other branches
- 5 contemplate.module \contemplate_node_view()
- 6 contemplate.module \contemplate_node_view()
Implements hook_node_view().
File
- ./
contemplate.module, line 180 - Create templates to customize teaser and body content.
Code
function contemplate_node_view($node, $build_mode) {
switch ($build_mode) {
case 'rss':
if ($template = contemplate_get_template($node->type)) {
if (CONTEMPLATE_RSS_ENABLED & $template['flags'] && trim($template['rss'])) {
// only if there's content in teaser field
$xml_elements = array();
$node->build = node_view($node, 'teaser');
$rss = contemplate_eval($template['rss'], $node, $xml_elements);
// set both teaser and body because we don't know how they've set Drupal
$node->teaser = $rss;
$node->body = $rss;
if (trim($template['enclosure'])) {
if ($file = contemplate_eval_enclosure($template['enclosure'], $node, $xml_elements)) {
$xml_elements[] = array(
'key' => 'enclosure',
'attributes' => array(
'url' => file_create_url($file->filepath),
'length' => $file->filesize,
'type' => $file->filemime,
),
);
}
}
$node->rss_elements = $xml_elements;
}
}
break;
}
}