function advanced_forum_theme_registry_alter in Advanced Forum 6
Same name and namespace in other branches
- 6.2 advanced_forum.module \advanced_forum_theme_registry_alter()
- 7.2 advanced_forum.module \advanced_forum_theme_registry_alter()
Implementation of hook_theme_registry_alter().
File
- ./
advanced_forum.module, line 89 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_theme_registry_alter(&$theme_registry) {
// Kill the next/previous forum topic navigation links.
if (!variable_get('advanced_forum_use_topic_navigation', FALSE)) {
foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_topic_navigation') {
unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
}
}
}
// --- The following section manipulates the theme registry so the .tpl files
// --- for the given templates can be found first in the (sub)theme directory
// --- then in ancestor themes, if any, then in the designated styles
// --- directory for advanced forum, and finally in the advanced forum naked
// --- style as a base style.
// Affected templates
$templates = array(
'node',
'comment',
'comment_wrapper',
'forums',
'forum_list',
'forum_topic_list',
'forum_icon',
'forum_submitted',
'author_pane',
'advf_forum_statistics',
'advanced_forum_topic_legend',
'advanced_forum_forum_legend',
'advanced_forum_topic_header',
);
// Find all our ancestor themes and put them in an array.
global $theme;
$themes = list_themes();
$ancestor_paths = array();
$ancestor = $theme;
while ($ancestor && isset($themes[$ancestor]->base_theme)) {
array_unshift($ancestor_paths, dirname($themes[$themes[$ancestor]->base_theme]->filename));
$ancestor = $themes[$ancestor]->base_theme;
}
$current_style = advanced_forum_path_to_style();
$naked_path = drupal_get_path('module', 'advanced_forum') . '/styles/naked';
foreach ($templates as $template) {
// Sanity check in case the template is not being used.
if (is_array($theme_registry[$template])) {
// If there was a path in there, store it.
$existing_path = array_shift($theme_registry[$template]['theme paths']);
// Slide the paths we are adding in before the existing one.
if ($naked_path == $current_style) {
// The style is already naked, so no need to add it twice.
array_unshift($theme_registry[$template]['theme paths'], $existing_path, $current_style);
}
else {
// Style is not naked so slip naked in as a default style.
array_unshift($theme_registry[$template]['theme paths'], $existing_path, $naked_path, $current_style);
}
// If there are any ancestor paths (ie: we are in a subtheme, add those)
foreach ($ancestor_paths as $ancestor_path) {
$theme_registry[$template]['theme paths'][] = $ancestor_path;
}
// Put the active theme's path last since that takes precidence.
$theme_registry[$template]['theme paths'][] = advanced_forum_path_to_theme();
}
}
}