Drupal: force the administration theme on additional non-admin paths


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

**Important: this snipplet has moved to Github.**

- [Force the admin theme on additional non-admin paths in Drupal 6](https://gist.github.com/1973090)


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. /**
  4.  * In this example, it uses the administration theme on "node creation", "node edition",
  5.  * "user registration", "user profile" and "forgot password" pages.
  6.  */
  7.  
  8. function MODULENAME_init(){
  9.  
  10. // The list of paths on which to use the administration theme
  11. $patterns = array(
  12. 'user',
  13. 'user/*',
  14. 'user/password',
  15. 'user/*/edit',
  16. 'user/*/geodata',
  17. 'node/add/*',
  18. 'node/*/edit',
  19. 'node/*/delete'
  20. );
  21.  
  22. $path = drupal_get_path_alias($_GET['q']);
  23.  
  24. $use_admin_theme = false;
  25. foreach ($patterns as $pattern){
  26. if (drupal_match_path($path, $pattern)){
  27. $use_admin_theme = true;
  28. break;
  29. }
  30. }
  31.  
  32. if ($use_admin_theme){
  33. global $custom_theme;
  34. $custom_theme = variable_get('admin_theme', '0');
  35. drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
  36. }
  37. }
  38.  
  39. ?>

URL: http://www.wildpeaks.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.