I'm rapid prototyping some content types in CCK, and I was hoping for a brief sanity check from anyone on the forums.

I'm trying to figure out 'the drupal way' to implement a data model in CCK. The user should be able to create a new node of type 'Product'. Then they'll choose certain Attributes about that product from an available list, and assign values to their chosen attributes. For different product nodes, the user will select different attributes.

I've created the following content types:
Product
Attribute
Product-Attribute-Value

The user can create a new product. The user can also create a new attribute. Finally, the user can create a 'Product-Attribute-Value' node where they select a Product and an Attribute from NodeReference lists. They input the actual value for the attribute on that final page.

I suppose the challenge is that I don't know ahead of time which Attributes will apply to a certain Product, so I want to build in the flexibility for the user to assign Attributes to Products, rather than having a set list of Attributes for each Product. The user has to create a new "Product-Attribute-Value" node for each new attribute value they want to assign to the Product. Is this a sensible way to proceed? Are there more elegant solutions out there? Thank you.

Comments

marcvangend’s picture

Why don't you just add all possible attributes to the 'product' type? As long as they're not set as required fields, it is no problem that some attributes do not apply to a certain product - you only fill in what applies. When you view a product, Drupal checks if an attribute has been set. If so, it is displayed, if not, the field and label are hidden.