Create EAV on Drupal with CCK
What's EAV? Entity-Attribute-Value.
It is mostly used for shopping cart websites where you have
things like Price, Color, etc.
I decided to write something like EAV with Drupal.
Using CCK I got a module named “CCK Taxonomy”,
and with CCK Version 6.x-3.x-dev (which last I checked is necessary for the next step),
I added a field of the type ‘Multigroup’ (Content Multigroup, should come with CCK).
Multigroup is essentially a group of several fields that you can
give them properties like 1 field, so you can “add more” Multigroup fields.
This is crucial to understand because a Taxonomy field usually looks like this:
‘Movie, Review, Horror.....”, but we want to match every Taxonomy with a value:
- Price - 20$
- Genre - Horror
- Media Type - Movie
so we need a value field (empty text field) for each Taxonomy field, or as I did it:
A Multigroup of 2 fields: Taxonomy+Text field.
With the configuration of Multigroup, you can let the user add as many fields as he wants.
Thanks to Taxonomy, you won’t have repeated attributes with slightly different spelling.
Everything will have 1 sortable entity which you can use later to sort your content types.
Later on I created my own .tpl (template file),
to take the data and represent it the way I wanted.
Hope this post helped anyone out there,
because it would definitely have helped me 3 months ago.