[Drupal] Using the admin theme when you deleting a node.

As we know that, in Drupal, it does not separate the front-end and back-end. Though we can set the back-end theme, but some time, it still displays the front-end theme, for example, when deleting a node, it will display the front-end theme but not the back-end theme you wish to, here is a way to build a very simple module to do it.

 

About the .info, please search the details in drupal.org, here i only provide the code of .module.

 

Let say the module "my_admin_node" is what we will build. Here is the codes of my_admin_node.module

 

代码
/**
 * Implementation of hook_init().
 
*/
function my_admin_node_init() {
  
// Use the administrative theme
  $arg_2 = arg(2);
  
if (
    
$arg_2 == 'delete'
    
|| $arg_2 == 'revisions'
    
|| (arg(0== 'user' && !empty($arg_2))
  ) {
    
global $custom_theme;
    
$custom_theme = variable_get('admin_theme', '0');
    drupal_add_css(drupal_get_path(
'module', 'system'.'/admin.css', 'module');
  }
}

 

yeah, you can see that is just a very simple module with a very simple way to do that,  and with this info, i hope you can build your own complex module. :)

 

Have fun with Drupal! 

posted @ 2011-01-18 17:34  DavidHHuan  阅读(303)  评论(0编辑  收藏  举报