assign drupal theme programmatically

1.7k views Asked by At

I know that we can assign a theme named page-name.tpl.php to a page called /page/ with the use of the theme engine.

How can i assign a theme to a template programmatically in drupal ?

3

There are 3 answers

1
mariomaric On BEST ANSWER

Maybe you can use Sections module?

c/p from project page:

This module allows you to create sections within your site. Each section has an installed template, theme or style attached to it.

Sections are shown based on:

  • Node specific visibility settings
  • Role specific visibility settings
  • Page specific visibility settings (regexped paths)
  • Custom PHP visibility snippets
0
ceejayoz On

You can use the global $custom_theme variable to change the theme.

http://api.drupal.org/api/drupal/developer--globals.php/global/custom_theme/6

global $custom_theme;
$custom_theme = 'garland';
0
dobeerman On
global $custom_theme;
$custom_theme = 'garland';
init_theme();