I wish to hardcode theme switching on certain paths in a module. Where can I find examples and such?

Thanks.

Comments

Anonymous’s picture

How about using ThemeKey: http://drupal.org/project/themekey

ManyNancy’s picture

No, I need to do this in my own module and I don't like the overhead.

Anonymous’s picture

In that case you can implement it in a hook like this:

function mymodule_init() {
    global $custom_theme;
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $custom_theme = variable_get('theme_default', '0');
        init_theme();
    }
}

In this example we switch the theme to the default theme on a node edit page.

ManyNancy’s picture

Oh thank you so much.

ManyNancy’s picture

So let's say I want to use Chameleon on the node edit page. (It's not my default theme)

Is it like this? Not working for me.

function mymodule_init() {
    global $custom_theme;
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $custom_theme = variable_get('chameleon', '0');
        init_theme();
    }
}

Thanks.

Anonymous’s picture

No actually it would be this:

function mymodule_init() {
    global $custom_theme;
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $custom_theme = 'chameleon';
        init_theme();
    }
}