You are here

function contemplate_get_file in Content Templates (Contemplate) 6

Same name and namespace in other branches
  1. 5 contemplate.module \contemplate_get_file()
  2. 7 contemplate.module \contemplate_get_file()

Given a node type and field type, return the content of the most specific file

Parameters

string $node_type: type of node

string $field: field type we're looking for possible values are 'body', 'teaser', and 'rss'

Return value

either path to the most specific file (string) or FALSE if no file is found

1 call to contemplate_get_file()
contemplate_get_template in ./contemplate.module
Get a single template

File

./contemplate.module, line 596
Create templates to customize teaser and body content.

Code

function contemplate_get_file($node_type, $field) {
  $files = contemplate_available_files();
  if (isset($files['node-' . $node_type . '-' . $field . '.tpl'])) {
    $file = $files['node-' . $node_type . '-' . $field . '.tpl'];
  }
  elseif (isset($files['node-' . $node_type . '.tpl'])) {
    $file = $files['node-' . $node_type . '.tpl'];
  }
  elseif (isset($files['node.tpl'])) {
    $file = $files['node.tpl'];
  }
  if (isset($file) && $file) {
    $file->contents = file_get_contents($file->filename);
    $return = $file;
  }
  else {
    $return = FALSE;
  }
  return $return;
}