zoukankan      html  css  js  c++  java
  • [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!

  • 相关阅读:
    Docker基础 ubuntu安装docker
    layui.laytpl 模板引擎用法
    golang 中 strings 包的 Replace 用法介绍笔记
    golang之结构体
    Mysql复习秘籍
    NFS 共享存储
    Rsyncd 同步服务
    企业服务器架构
    基础面试题二
    基础面试题一
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/1827337.html
Copyright © 2011-2022 走看看