在Drupal中禁用/节点视图和其他隐藏视图? [英] Disabling /node view and other hidden views in Drupal?

查看:99
本文介绍了在Drupal中禁用/节点视图和其他隐藏视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上花费了很长时间的夜晚,现在我已经开始进行各种安全检查,并且偶然发现以下情况:

Many long nights spent on my site, and now I've started doing all sorts of security checks and stumbled upon the following:

www.mysite.com/node

显示用户有权访问的最新x节点至。我不希望用户看到这个视图。我当然不希望有任何类似这样的看法。所以,我的问题是:

That shows the latest x nodes that a user has access to. I DON't want this view visible to users. And I certainly don't want any other views similar to this available. So, my questions are:


  1. 如何禁用此视图?

  2. 是否有其他隐藏意见我不知道匿名用户可以一次访问多个节点?


推荐答案

您要在自定义模块中使用 hook_menu_alter()重新路由当有人尝试在 / node 加载页面时会发生什么。有两种方法。

You want to use hook_menu_alter() in a custom module to reroute what happens when someone tries to load the page at /node. There are two approaches.

首先,您可以拒绝明确的访问:

First, you could give an unequivocal access denied:

function custom_module_menu_alter(&$items) {
  $items['node']['access callback'] = FALSE;
}

其次,您可以将页面重新路由到您选择的一个:

Second, you could reroute the page to one of your choice:

function custom_module_menu_alter(&$items) {
  $items['node']['page callback'] = 'custom_module_new_page_content';
}
function custom_module_new_page_content() {
  return 'Go away!';
}



其他列表



如果您担心用户可以访问的列表,搜索结果和跟踪器是唯一可以回忆的地方。

Other Listings

If you are worried about listings where users have access, the search results and tracker are the only other places that I can recall.

此评论提供了使用自定义模块从搜索结果中取消设置任何内容的逻辑。

This comment provides the logic to unset whatever you want from the search results using a custom module.

不幸的是,跟踪器不是特别可定制的,没有直接的黑客。你最好的选择是使用contrib中的一个跟踪器替换,或者更容易地修改与Views模块一起打包的Tracker替换。

Unfortunately the Tracker is not particularly customizable without direct hacks. Your best bet is to use one of the tracker replacements in contrib, or easier yet, modify the Tracker replacement that is packaged with the Views module.

编辑:澄清 - 你也可以从可选的核心模块中禁用跟踪器模块。但是,这是一个非常有用的功能,因此您可能希望以某种形式保留它。

Clarification- you could also disable the Tracker module form the optional "core" modules. However, it is a very useful functionality so you might want to keep it around in some form.

这篇关于在Drupal中禁用/节点视图和其他隐藏视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆