[Drupal] Use administrative theme when deleting or reviewing the content node

As we know, in drupal, the frontend and backend are mixed together, but when we click the button "delete" or "revisions" of a node, we are redirected to frontend, so how can we set to stay in backend when doing that?

 

Thanks to the implement of drupal, we can hook the hook_init() function to do that. Here is a way to build a module called "my_admin_node"

 

About how to build a module in drupal, please google it :)

 

In the my_admin_node.module file, we write the code as below for example:

代码
<?php
// $Id:


/**
* 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');
}
}
so when we visit node/111/delete, we will still stay in backend but not redirected to frontend.

 

Have fun with drupal!

posted @ 2010-09-15 18:14  DavidHHuan  阅读(298)  评论(0编辑  收藏  举报