How to change theme on on a single view programmatically based on path

This is how you can change theme on a single view programmatically based on path. In my case I have made some own modules and I want those views using the current admin theme instead of the default theme. I let the path decide what theme to use in hook_init. I also thought it all user views should have the admin theme.

<?php
/**
* hook_init()
*
*/
function support_filter_init() {
//Use admin theme in all paths like /domainuser*, /support_filter* and /user*
 
if (arg(0) == "domainuser" OR arg(0) == "support_filter" OR arg(0) == "user") {
    global
$custom_theme;
   
$custom_theme = variable_get('admin_theme', '0');
   
//$custom_theme = "rootcandy"; //if you need another theme
   
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
  }
}


?>

This version checks the node type if it's arg(0) is node as it is when viewing a node, even if you have url alias.

<?php
function support_filter_init() {
  global
$user;

 
drupal_add_css(drupal_get_path('module', 'support_filter') .'/support_filter.css');


  if (
$user->uid > 0) {
     
$segment_1 = array("domainuser",
                        
"support_filter",
                        
"user",
                        
"backup-support",
                        
"support");

      if (
arg(0) == "node") {
           
$ticket = db_fetch_object(db_query('SELECT type FROM {node} WHERE nid = %d AND type = "support_ticket"', arg(1)));
            if (
$ticket) {
           
$segment_1[] = "node";
            }
      }

      if(
in_array(arg(0), $segment_1)) {
        global
$custom_theme;
       
$custom_theme = variable_get('admin_theme', '0');
       
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
      }
  }


}
?>
Knowledge keywords: