The website I'm building has a lot of content that I do not want linkable to the actual node. Is there a way to remove the link in the content headers?
1 Answer
There are a lot of different methods for doing this.
The basic idea is to detect the content type using one of a few methods and calling drupal_not_found()
. When doing this, I typically set the pathauto for these to no-view/[nid]
, and then detect the request_uri
in a hook. There are some variations, but the all do something really similar.
However, there is a newish module called Rabbit Hole that eliminates the need for custom modules and provides a lot of flexability to how you hide the content. I had been working on a general use module that did something similar, and abandoned developing it when I found this. From the project page:
[It] works by providing multiple options to control what should happen when the node is being viewed at its own page. You have the ability to
- Deliver an access denied page.
- Deliver a page not found page.
- Issue a page redirect to any Drupal path.
- Or simply display the content (regular behavior).
This is configurable per content type and per node. There is also a permission that lets certain roles override Rabbit Hole completely.
-
I'm implementing Rabbit Hole to return them to the frontpage if anyone attempts to access the node directly, and I ended up creating some PHP directives in node.tpl.php based on the taxonomy of the content. The reason I approched it with this method is to give control to editors/content builders to either link it or not link via the content title just by entering a taxonomy term. I added a couple additional functionality like to be able to remove titles altogether, and even disable publishing information. However, rabbit hole is a fallback in case someone attempts to hack the URL to access it. Commented Mar 30, 2012 at 17:19