14.11. How to change the PHP-Nuke theme depending on the module

For some web designs, it is desirable to always use the same theme for a few modules, while letting the user choose his own theme for the rest. Let's say you want to use the NukeNews theme for the News and Sections modules, but let the user's personal theme be applied to the other modules of your site.

The theme is set in the get_theme function of mainfile.php. Thus, all you have to do is declare the $name variable to be global in that function, then check its value before the selected theme is returned (i.e. immediately before the return statement) and, if it is, say "News", or "Sections", to choose the NukeNews theme (see Truly Global Variables):

function get_theme() {
    global $user, $cookie, $Default_Theme, $name; (1)
    if(is_user($user)) {
        $user2 = base64_decode($user);
        $t_cookie = explode(":", $user2);
        if($t_cookie[9]=="") $t_cookie[9]=$Default_Theme;
        if(isset($theme)) $t_cookie[9]=$theme;
        if(!$tfile=@opendir("themes/$t_cookie[9]")) {
            $ThemeSel = $Default_Theme;
        } else { 
            $ThemeSel = $t_cookie[9];
        }
    } else {
        $ThemeSel = $Default_Theme;
    }
    if ($name == "News" || $name == "Sections") { (2)
        $ThemeSel = "NukeNews"; (3)
    } else {
        /* Don't change the theme */    
    }
    return($ThemeSel);
}
(1)
Declare $name to be global.
(2)
Check if the module name, $name, is News or Sections.
(3)
Set the selected theme to NukeNews.

Of course, there is nothing magic about $name. You could take just any other variable and make the theme selection be dependent on it. You would only have to declare it global in the get_theme() function and in the modules that you would like to se t it.