I need to speak to the Jedi Council. The situation has become much more complicated.
This is pretty much what I thought to myself a few weeks ago when a project I was working on presented me with an interesting problem. I had just finished importing data from an external source into Drupal when I learned that in addition to the brand-new 3,000+ nodes, we somehow also had to take into account several thousand more "aliases" for each node. Keep in mind that I'm not talking about "aliases" in the normal Drupal sense...
In this case, each imported node had the possibility of having multiple titles and each title needed to be available in various Views and discoverable via Drupal's core search mechanism. It was a requirement that we didn't just duplicate node content and give each duplicate a new title. We needed "phantom" nodes.
To illustrate the problem, take a look at a simple example. In this diagram, there is a "red" node of content type "color". In addition, there are 6 "phantom" nodes - each of these has a unique title, but they still all refer to the same "red" node. So, in a view that displays all the colors, each of the "real" and "phantom" nodes is displayed without bias. But, when a user clicks on one of the "phantom" nodes, they are automatically redirected to the "red" node. Make sense?
The solution I came up with was to create a new "phantom" content type that only had several features: a title, a CCK Redirection field to store the path to the "real" node, and taxonomy identical to the "real" content type.
Here's a quick look at the "color" content type:
Nothing special going on here - this is a pretty typical content type with a few text fields and an associated "color vocabulary" taxonomy vocabulary activated.
All the content types and views I used in this example are available for download at the bottom of this article.
Now take a look at the "color_phantom" content type:
This content type has access to the same taxonomy as the "real" content type (this will be useful later when doing some Views filtering), but none of the descriptive text fields. Plus, it has the super-special "real path" field.
The "real path" (CCK Redirection) field is a separate download from the core CCK module and it provides a simple text field with some options. I used it in its most simple form - just as a straight-forward "divert". The module provides some additional options to pause for 5 seconds before diverting, or opening up the redirection path in a frameset.
Once I had my content types set up, I created a "red" node (borrowing content from Wikipedia):
Node the taxonomy term, "happy" near the bottom of the node. Again, nothing special going on here. I'll use this later in a sample view.
Now, I'll create a "phantom" node. Before I do this though, I need to take note of the "red" node's path by looking at my browser's address bar:
In this case, I'll need to remember "node/13" for the next step (the "http://localhost:8888/drupaleasy/" part is the path to my local Drupal installation, I only need the "internal path".)
To create each phantom node, I simply clicked to create a new "Color phantom" node and gave it a unique title, the same taxonomy as the "real" node, and the path to the real node:
Pretty straight-forward, right? Nothing fancy. Based on the initial diagram in this article, I went ahead and created 5 additional phantom nodes. When I was done, my admin/content/node page looked like this:
Now, if you're logged in a User 1 (the initial user you used when you set up your web site - the one with all the power), when you click to visit one of your phantom nodes, you won't be redirected anywhere. You'll just see a message:
This is because the CCK Redirection module has a built-in permissions (on the admin/user/permissions page, obviously) to "bypass redirection". As User 1, you'll never-ever-ever-never be redirected. You'll need to logout then try to view the "scarlet" node - then you'll be redirected automagically to the "Red" node.
At this point, all of the "difficult" work is done. I can easily set up a view to show all the colors and color phantoms and have them all go to the correct node when clicked on. Furthermore, since I duplicated the taxonomy on the phantom nodes, I can also filter the views using taxonomy. If you want to be able to filter on other fields, you'll most likely have to have some duplicate content - I haven't been able to figure out a way around that just yet.
Here's a quick look at the view I set up to demonstrate:
There's one more cool thing you can do with the CCK Redirection module - it doesn't have to redirect to a node - it can redirect to anything. Think about that for a second...
Imagine that you're creating a view that isn't a simple list like the one I just created. Imagine it's a slideshow of some type. Then, you can mix and match nodes, other views, taxonomy pages, even external URLs in a single view. You can then add an image field to each node that uses the CCK Redirection field and display the image in the view, then when the user click on the image, they're redirected to the appropriate place.
With this new power, you'll feel like you can take on the whole Empire by yourself. May the force be with you.
I use cck_redirection for all of my sites where *anything* might link to an external URL to be able to have something locally that shows in up the search engine. A typical example is a 3rd party subscription service: if you just have it as a normal link, e.g. in the menus, when someone searches your site for "subscribe" they won't be able to find that link unless you create a page with a CCK_Redirection and load it with lots of relevant keywords. Good stuff.