function contemplate_get_template in Content Templates (Contemplate) 6
Same name and namespace in other branches
- 5 contemplate.module \contemplate_get_template()
- 7 contemplate.module \contemplate_get_template()
Get a single template
Return value
array template
4 calls to contemplate_get_template()
- contemplate_edit_type_form in ./
contemplate.module - Menu callback Edit the template for a specific node-type
- contemplate_features_export_render in includes/
contemplate.features.inc - Implementation of hook_features_export_render().
- contemplate_get_templates in ./
contemplate.module - Get all of the current templates Only used on admin page
- contemplate_nodeapi in ./
contemplate.module - Implementation of hook_nodeapi().
File
- ./
contemplate.module, line 471 - 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));
if (empty($types[$type])) {
$types[$type] = array(
'flags' => 0,
);
}
// 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];
}