2

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 ?

user550265
  • 3,171
  • 8
  • 44
  • 55

3 Answers3

4
global $custom_theme;
$custom_theme = 'garland';
init_theme();
dobeerman
  • 1,354
  • 15
  • 27
1

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
mariomaric
  • 166
  • 2
  • 5
  • Sections certainly provides access to this system, but it's just one of countless modules that approach this problem for one reason or another. Answering the question asked is @dobeerman and @ceejayoz. – Grayside Mar 05 '11 at 00:21
1

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';
ceejayoz
  • 176,543
  • 40
  • 303
  • 368