Can't think of Taxonomy, CCK fields or Nodes solution for one field
olalindberg - November 15, 2007 - 09:03
I'm building a Business Directory web site (think Yellow Pages) in Drupal. I have created one Content Type called Company that represent companies in my site. It holds fields such as company name, website, logo, phone number, etc. Now I would like to add another field to my companies called Distributors but I can't decide how to implement that in Drupal.
Here are my ideas about my Distributors:
- Each company can have several Distributors
- Each Distributor has some associated information (like e-mail, website, phone number, etc)
- My site administrator is the one that associates companies with it's Distributors (and not the customer registering the company).
- My Distributors are categorized in a one level deep three (distributor category holds several distributors)
Ideas for solutions:
- Add CCK Fields to my Company Content Type and use the CCK Field Permissions module (http://drupal.org/project/cck_field_perms) to limit those fields to be editable by site administrator only. This would work but I get (at least) two disadvantages; I will not be able to do sorting on Distributors and the site administrator will have to type the information for every company.
- Create a Taxonomy Vocabulary for each Distributor Category and add my Distributors as a Content Type called Distributors. Then I guess that I can make related node relations between my Companies and the Distributor node.
- It feels like I'm missing the obvious here. Am I? It feels like it would be great if I could make some connection between a Taxonomy Term and a Node? But again I'm clueless here.
Any ideas on how I can make it work?

Using Views
After some Discussion (big thanks to http://groups.drupal.org/user/2689 and http://www2.drupal.org/user/196421 !) I think I realize one solution.
Create the following:
See this image for a sketch: http://static.olalindberg.com/drupal/071122_content_types.png
I set up my Select Distributor View to take a Taxonomy Term name as argument. This argument is one Term from the Taxonomy Vocabulary Distributor. The View returns a list of all companies that are in this Distributor Category.
I'm not sure on the details for the following yet.
When a Company is created I will select a Distributor Node (Content Type Distributors). When this is selected it queries the view that returns a list of Distributors that's in this category and populates those in another drop down in the company. To clarify:
The optimal solution would be to allow multiple distributor selections but that's probably the next step!
Node Reference - Views
I think I'm really close.
I found that it was possible to select a view in the Node Reference configuration page (see this image: http://static.olalindberg.com/drupal/071122_NodeReference_Views.png). I think there is only one thing left to do now. Make the View arguments as a drop down from taxonomy distributor categories. No idea at all how that's done though...
I'll report back when I'm on a solution!
Can't find a solution
I hadn't been able to work this out jet so I created a feature request in the CCK module (http://drupal.org/node/194491).
Multiselect
Well it's not perfect but it works.
For now I'll be using the Multiselect module (http://drupal.org/project/multiselect) and select from a huge list of nodes.