Posted By

wildpeaks on 11/06/10


Tagged

module drupal theme drupal6


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

wildpeaks
Onfire60
ratbagash


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


 / Published in: PHP
 

URL: http://www.wildpeaks.com

Important: this snipplet has moved to Github.

  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. ?>

Report this snippet  

You need to login to post a comment.