function content_theme_custom_theme in Content Theme 7
Same name and namespace in other branches
- 7.2 content_theme.module \content_theme_custom_theme()
Implements hook_custom_theme().
File
- ./
content_theme.module, line 116 - This module allows to use different themes than the site default on content creating, editing, and viewing pages.
Code
function content_theme_custom_theme() {
if (arg(0) == 'node' && (is_numeric(arg(1)) || arg(1) == 'add' && !is_null(arg(2)))) {
if (arg(1) == 'add') {
$theme_node = FALSE;
$theme_type = variable_get('content_theme_content_type_edit_' . str_replace('-', '_', arg(2)), '-content_wide-');
$theme_wide = variable_get('content_theme_content_wide_edit', '0');
}
elseif (arg(2) == 'edit') {
$theme_node = db_query('SELECT theme FROM {content_theme_node} WHERE nid = :nid AND action = :action', array(
':nid' => arg(1),
':action' => 'edit',
))
->fetchField();
$theme_type = variable_get('content_theme_content_type_edit_' . db_query('SELECT type FROM {node} WHERE nid = :nid', array(
':nid' => arg(1),
))
->fetchField(), '-content_wide-');
$theme_wide = variable_get('content_theme_content_wide_edit', '0');
}
else {
$theme_node = db_query('SELECT theme FROM {content_theme_node} WHERE nid = :nid AND action = :action', array(
':nid' => arg(1),
':action' => 'view',
))
->fetchField();
$theme_type = variable_get('content_theme_content_type_view_' . db_query('SELECT type FROM {node} WHERE nid = :nid', array(
':nid' => arg(1),
))
->fetchField(), '-content_wide-');
$theme_wide = variable_get('content_theme_content_wide_view', '0');
}
if ($theme_node !== FALSE && $theme_node != '-content_wide-') {
$custom_theme = $theme_node;
}
else {
if ($theme_type != '-content_wide-' && !$theme_node) {
$custom_theme = $theme_type;
}
else {
$custom_theme = $theme_wide;
}
}
return $custom_theme;
}
}