2

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

4

1 回答 1

7

Edit: here is a simpler example.

It uses Garland regardless of the theme setting. Note that this overrides the admin theme setting too.

function MODULENAME_init(){
    global $custom_theme;
    $custom_theme = 'garland';
}

Edit: changing globally.

And if you meant changing the theme setting in the database instead of just on the current page, here is how:

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

// Changes only the administration theme to Garland
variable_set('admin_theme', 'garland');
于 2010-10-21T21:10:06.683 回答