function content_theme_init in Content Theme 6
Implementation of hook_init().
File
- ./
content_theme.module, line 41 - This module allows to use different themes than the site default on content creating, editing, and viewing pages.
Code
function content_theme_init() {
if (arg(0) == 'node' && (is_numeric(arg(1)) || arg(1) == 'add' && !is_null(arg(2)))) {
global $custom_theme;
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_result(db_query('SELECT theme FROM {content_theme_node} WHERE nid = %d AND action = "edit"', arg(1)));
$theme_type = variable_get('content_theme_content_type_edit_' . db_result(db_query('SELECT type FROM {node} WHERE nid = %d', arg(1))), '-content_wide-');
$theme_wide = variable_get('content_theme_content_wide_edit', '0');
}
else {
$theme_node = db_result(db_query('SELECT theme FROM {content_theme_node} WHERE nid = %d AND action = "view"', arg(1)));
$theme_type = variable_get('content_theme_content_type_view_' . db_result(db_query('SELECT type FROM {node} WHERE nid = %d', arg(1))), '-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;
}
}
}
}