function contemplate_get_template in Content Templates (Contemplate) 5
Same name and namespace in other branches
- 6 contemplate.module \contemplate_get_template()
- 7 contemplate.module \contemplate_get_template()
Get a single template
2 calls to contemplate_get_template()
- contemplate_edit_type_form in ./
contemplate.module - Menu callback Edit the template for a specific node-type
- contemplate_nodeapi in ./
contemplate.module - Implementation of hook_nodeapi().
File
- ./
contemplate.module, line 424 - Create templates to customize teaser and body content.
Code
function contemplate_get_template($type) {
//only load each template once per page hit
static $types = array();
if (!isset($types[$type])) {
// first check to see what's stored in the contemplate table
$types[$type] = db_fetch_array(db_query("SELECT * FROM {contemplate} WHERE type = '%s'", $type));
// now check to see if there are files
$fields = array(
'teaser' => CONTEMPLATE_TEASER_ENABLED,
'body' => CONTEMPLATE_BODY_ENABLED,
'rss' => CONTEMPLATE_RSS_ENABLED,
);
foreach ($fields as $field => $enable) {
if ($file = contemplate_get_file($type, $field)) {
$types[$type][$field] = $file->contents;
$types[$type][$field . '-file'] = $file;
$types[$type]['flags'] |= $enable;
// if there is a file, the field is always enabled...
}
$types[$type][$field . '-enabled'] = $types[$type]['flags'] & $enable ? TRUE : FALSE;
}
}
return $types[$type];
}