Samuli Natri
Oct. 11, 2016
Updated: Dec. 03, 2016
0
By Samuli NatriOct. 11, 2016
(Updated: Dec. 03, 2016)
0

Rabbit Hole Module (Drupal 8 Tutorial) (Article + Video)

Control what should happen when an entity is being viewed at its own page.

Use Case

  • You have a view that lists articles but you want to disable access to single articles in node/[nid]

Installation

drush -y en rabbit_hole

Note: at the moment (2016.12.01) there isn't a stable release available.

How To Use It

  • Go to admin/modules and enable the entity types you want to restrict access to:

  • Go to admin/structure/types/manage/article and you can find the Rabbit Hole settings at the bottom.
  • Select Access denied as the behavior:

Now you can see the articles listed in the front page:

But if you click them, you get access denied:

Options

  • Go to /admin/structure/types/manage/article

You can also choose Page not found behavior or make a Page redirect.

Install Token module to see the token widget in the image: https://www.drupal.org/project/token

In this case you would be redirected to the login page whenever you try to access an article in node/[nid].

Overrides And Permissions

You can allow these settings to be overridden for single entities in /admin/structure/types/manage/article:

  • Edit any article and you have the option to change the behavior for that single entity:

You can also allow certain roles to bypass Rabbit Hole in /admin/people/permissions:

Samuli Natri is the founder of WDTutorials.com. He started building Drupal sites in 2010 with Drupal 6. He attended Helsinki University and Helsinki University of Technology (Social Sciences and Computer Science). Read more...

Add new comment