以编程方式更改活动Drupal主题的正确方法是什么?

mar*_*son 2 php drupal drupal-themes

以编程方式更改活动Drupal主题的正确方法是什么?

wil*_*aks 7

编辑:这是一个更简单的例子.

无论主题设置如何,它都使用Garland.请注意,这也会覆盖管理主题设置.

function MODULENAME_init(){
    global $custom_theme;
    $custom_theme = 'garland';
}
Run Code Online (Sandbox Code Playgroud)

编辑:全球变化.

如果您的意思是更改数据库中的主题设置而不是仅更改当前页面,请按以下步骤操作:

// Changes the theme to Garland
variable_set('theme_default', 'garland');

// Changes only the administration theme to Garland
variable_set('admin_theme', 'garland');
Run Code Online (Sandbox Code Playgroud)