Posted by indianerrostock on March 25, 2009 at 11:11pm
Hi,
I have a question about creating relationships between nodes.
Lets say, we have the following two (imaginary) node types:
Node A and Node B
Node A has the fields:
nid, vid, name, birth
Node B has the fields:
nid, vid, name, type
Now my question:
I want to create a relationship between these two nodes with the hep of CCK. The relationship should be from Node A to Node B. Additionally, I want to add a 'year' to the relationship that is not a field in Node A or Node B.
I know that you can create relationships between nodes by the help of nodereference. But how can I add a 'year' field, which describes the relationship?
It would be great, if anybody could help me.
Comments
Use a 'join' content type
Have you tried creating a third content type that "joins" A and B via node references and also has a year field?
Need common field
Normally, you will create relationships using nodereference and the two content types then have a shared field and also ensure that data is entered once and relationship is consistent.
You can try the following:
- Add year as CCK on Node A
- Add same CCK field (as existing) to Node B
You will have established a relationship that can be used using Views. However, when you have the Year data entered, it will need to be entered once on each content type.
It may establish relationship but I am not sure how you will be able to use it.
----------------------------------------------------------
- Rajeev, Drupaler in South Bay Area
CCK
Look for the "Node reference" module in CCK. Use Views "Relationships" to join the tables togather.
Let me give an example that will be a little bit more detailed
I need a 1:n relationship between these two Nodes with an additional information at the relation.
Let me give an example. Node A could be a soccer team. Node B is a title node. Lets say we have 3 titles. The championship, the champions league and the national cup. We want to connect the soccer team with one of the titles, if the team wins the title. The relationship would be: Node A is connected to title B at year 2005. Another connection would be Node A is connected to title B at year 2007. Thart means, the team has won the title in 2005 and 2007. The relation consists of the two nodes and the year. The year is not stored in the Node A or the Node B. Its just a field of the relation.
I don't think that only views can help here. I have to create the relation and the year has to be stored somewhere.
Any idea about that example, how I can solve that problem?
_
You could create a content type of 'year' but that seems silly. I would just do this as a cck or taxonomy field for year on the title content type.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.