Hi,

I'm currently in the design phase for a system that's going to based on Drupal 6. One of the Content Types we're going to have is a Place. Each Place has some properties such as a coordinate, title, etc, and a list of 0..n Attributes key-value pairs, such as:
- Opening Hours (value is a set of Periods, or Intervals)
- Price (value is currency)
- Accessibility (value is Accessible / Non accessible)

Point is, each Attribute needs to have a Name and a Data Type as the key, and a value, the data type of which depends on the attribute.

Each place should, as I said, have a set of Attributes.

The brute-force solution would be developing a Node Module to take care of everything for the Place Node. Thus, I will have a {places} table, an {attributes} table which will hold all of the available attributes to choose from, and an {places_attribute_values} table, which will hold, for each place, all of its attributes and values.

In the UI side, I will have a regular form for the static attributes, and multiple lines of
tags for Attributes and text fields / checkboxes / radiobuttons (dynamically determined by the chosen Attribute data type).

I was wondering whether anyone can think of a way to implement this using CCK and Taxonomy.

Question number 1: Can I add a Taxonomy term to a Taxonomy term? Meaning, I will have one Vocabulary for Attributes and one Vocabulary for Data Types. Each Attribute term should have a Data Type term assigned.

Question number 2: Can I define a CCK field with multiple key/value pairs (ignoring the issue of storing different data types into the database - for the attribute values) where the keys are Taxonomy terms?

Any hint would be greatly appreciated.

Cheers

Shai

Edited by WorldFallz - moved to appropriate forum.

Comments

electricmonk’s picture

Anyone?

greg.harvey’s picture

I know this is old, but it ranks highly in Google, so I'll leave a response for those who surf in.

The Matrix module seems to do what you want. The Drupal 6.x version is still in beta and probably will be forever, but hopefully the maintainer will continue in to Drupal 7. It's useful functionality. I've needed it several times over the years:
http://drupal.org/project/matrix

texas-bronius’s picture

It's an interesting question. We are talking about object relational database design here, I guess. I have a similar problem, and I don't think Matrix is the solution. I have an event that can have multiple guest readers, and each guest reader will have a bio text and a bio pic. I am about to just settle for Allow Multiple Values and count on the user/editor to pair them properly. It's not elegant, but it will work.

--
http://drupaltees.com
80s themed Drupal T-Shirts

ha5bro’s picture

Link CCK has a pair of text field values that are in the same array. But you don't actually have to enter a URL, it'll accept any text value. The beauty of this is that the link fields can be rearranged by the user and the arrays can be passed to other custom functions that can do stuff like calculations, etc. Requires a bit of form hacking in template.php but nothing major.

In your node.tpl.php you could do something like this,

	$tally = 0;

	// field_testlink is the CCK link field
	echo "<ul> \n";
    foreach($node->field_testlink as $item) {
    	echo "<li>";
		echo "<label>" . $item['title'] . "</label>";
		echo "&nbsp;<span style='color:#cc0000'>" . $item['url'] . "</span>";
		echo '<br />';
        echo "</li> \n";
        // tally the results of the 'url' value
        $tally+=$item['url'];
    }
    echo "</ul> \n";
    echo "<label>Total Course Credits:</label><span style='color:#cc0000'>" . $tally . "</span>";
mandclu’s picture

I found this thread from Google as well. As it turns out there is an effort underway to merge the two modules mentioned by dman, since neither is really complete and both have their own strengths. AFAIK the most usable solution is currently at:
http://drupal.org/node/762932#comment-2820802