Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to restrict direct access to the nodes but just allow views to access the required field of the particular node type, for example in views slide show we are sliding the image field belongs to particular node type. But we don't want search engines to access & visitors to access the nodes belong to that node type

share|improve this question

migrated from stackoverflow.com Sep 11 '11 at 5:11

This question came from our site for professional and enthusiast programmers.

A simple solution would be to not publish the nodes you don't want to be accessible. Views can still pull the data from those nodes.

share|improve this answer
thanks bro it's too simple solution. – Fahad Sep 11 '11 at 6:46
Too simple? There is no such thing as a 'too simple solution'. Complexity isn't a goal in itself, is it? Perhaps Googletorp's answer doesn't solve your specific problem, but in that case you will have to be more elaborate and explain why not. – marcvangend Sep 11 '11 at 8:19
+1 Great solution.. – Evil Angel Sep 14 '11 at 4:26
@marcvangend Though it's late but I have realize that is not the answer of my question. Hope some one can add a better answer – Fahad Dec 8 '12 at 22:31
@Fahad To get better answers, you need to ask better questions. Googletorp's answer looks like a good solution to me, and the upvotes seem to agree. If it doesn't solve your problem, go in and edit your question, adding all relevant details. – marcvangend Dec 9 '12 at 7:46
up vote 3 down vote accepted

If we unpublish nodes added by user1 they wont be editable by any other user even if the user have the rights to edit the content of that content type.

Restrict Node Page View seems a better way to restrict the direct access to any nodes of specific content type.

Usage is also fairly simple you just need to enable this module and configure the permissions for the nodes which are directly accessible as normal.


Have you ever used a slideshow nodetype that you need to be published but don't want the node be accessible by itself using then node/XXX path? This module is for you!

With this module you can disable direct access to node pages (node/XXX) based on nodetypes and permissions.

Enable the module and don't forget to configure your permissions.

share|improve this answer

An other module who do the same thing but with more functionalities.

Rabbit Hole

Maintainers of this project ask to "Restrict Node Page View" Maintainer to merge projects in issues.

Advantages against "Restrict Node Page View" :

  • Same main functionality on node but extensible to users/files/taxonomy terms
  • Can be used in your module
  • Can be global to content type or on every content
  • See more on project page...

Disadvantage against "Restrict Node Page View" :

  • More code so possibly less effective (need tests, not proved)
share|improve this answer

you should use node_access(), there are certain options that you can easily implement using hook_node_access(). Implementing node_access() allows you to make a decision as to who can access a node and who can create, delete, edit, or update such a node. Views, however, can still pull data from these nodes whatsoever.

hook_node_access(), node_access()

share|improve this answer

Inspired by https://www.drupal.org/project/restrict_node_page_view you might write a small module yourself:

 * Implements hook_node_access()
function MYMODULE_node_access($node, $op, $account) {

  // Default checks
  if (!is_object($node)) {

  $type = is_string($node) ? $node : $node->type;

  if($op == 'view' && arg(0) == 'node' && arg(1) === $node->nid) {

    // Restrict access to full MYTYPE node for anon users
    if ($type == 'MYTYPE' && user_is_anonymous()) {
      return NODE_ACCESS_DENY;
  // Default
share|improve this answer
This module was already mentioned couple of years ago. Could you explain what new your answer brings to the subject? – Mołot Aug 19 '15 at 9:18
@Mołot - ...to write a module yourself. Edited answer. – leymannx Aug 19 '15 at 9:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.