Drupal - Programatically trigger another theme

/ Published in: PHP
Save to your folder(s)

This example triggers the admin theme when on any of the user/* pages (login, edit, etc.). Put the name of your admin theme in {admin-theme-name} so there's a safe fallback in case variable_get doesn't find the admin_theme.

Copy this code and paste it in your HTML
  1. $match = preg_match('/(user$)|(user\/)/', $_SERVER['REQUEST_URI']);
  2. if ($match) {
  3. global $conf;
  4. $conf['theme_default'] = variable_get('admin_theme', '{admin-theme-name}');
  5. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.