Return to Snippet

Revision: 35394
at March 5, 2012 00:52 by wildpeaks


Updated Code
<?php

/**
 * In this example, it uses the administration theme on "node creation", "node edition",
 * "user registration", "user profile" and "forgot password" pages.
 */

function MODULENAME_init(){

	// The list of paths on which to use the administration theme
	$patterns = array(
		'user',
		'user/*',
		'user/password',
		'user/*/edit',
		'user/*/geodata',
		'node/add/*',
		'node/*/edit',
		'node/*/delete'
	);

	$path = drupal_get_path_alias($_GET['q']);

	$use_admin_theme = false;
	foreach ($patterns as $pattern){
		if (drupal_match_path($path, $pattern)){
			$use_admin_theme = true;
			break;
		}
	}

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

?>

Revision: 35393
at November 6, 2010 19:16 by wildpeaks


Initial Code
<?php

function MODULENAME_init(){

	// The list of paths on which to use the administration theme
	$patterns = array(
		'user',
		'user/*',
		'user/password',
		'user/*/edit',
		'user/*/geodata',
		'node/add/*',
		'node/*/edit',
		'node/*/delete'
	);

	$path = drupal_get_path_alias($_GET['q']);

	$use_admin_theme = false;
	foreach ($patterns as $pattern){
		if (drupal_match_path($path, $pattern)){
			$use_admin_theme = true;
			break;
		}
	}

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

?>

Initial URL
http://www.wildpeaks.com

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

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

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

Initial Tags
module, drupal, theme

Initial Language
PHP