比如 我设置一下 http://www.example.com?a=1 就用一个主题 a=2就用另一个主题,如何实现?
谢谢!
if (isset($_GET['theme']) && is_string($_GET['theme'])) { global $custom_theme; $custom_theme = $_GET['theme']; }
把上面的代码加到hook_init里面试试,代码稍微做调整一下!
试过这个模块 ThemeKey 吗?里面可以配置很多规则,包括 Drupal: $_GET['q'] - Current value of Drupal's query parameter "q"
这个推荐写在Hook_custom_theme
/** * Implements hook_custom_theme(). */function mymoduleglobal_custom_theme() { if (user_is_admin()) { return 'seven'; } else { return 'mycustomadmin_theme'; }}