[Drupal] Use administrative theme when deleting or reviewing the content node
时间:2010-09-15 来源:DavidHHuan
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:

<?phpso when we visit node/111/delete, we will still stay in backend but not redirected to frontend.
// $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');
}
}
Have fun with drupal!
相关阅读 更多 +