Node references - the module node relationships

Soumis par Hagen Graf le 16. août 2009 - 14:27

I often have the problem to visualize relationships between nodes. Sometimes I use blocks in views with parameters, sometimes I embed views in node templates and so on. Another problem is often the kind of relationship between nodes. Sometimes they have a relationship vice versa, sometimes not. But I don't want to bother you with these things ...

The reason why I am writing this entry is, that I have found a good module helping me to get my job done: noderelationships.

The Task: Who is doing what with whom?

We have three actors: persons, partners and projects

We want to have a website with a few relationships

I often have the problem to visualize relationships between nodes. Sometimes I use blocks in views with parameters, sometimes I embed views in node templates and so on. Another problem is often the kind of relationship between nodes. Sometimes they have a relationship vice versa, sometimes not. But I don't want to bother you with these things ...

The reason why I am writing this entry is, that I have found a good module helping me to get my job done: noderelationships.

The Task: Who is doing what with whom?

We have three actors: persons, partners and projects

We want to have a website with a few relationships

A person:

  • is involved in one or many projects
  • works for one or many partners

A partner (usually a company or an NGO):

  • is involved in one or many projects

A project

  • has one partner as the lead partner
  • has one person as project coordinator

We need listviews of:

  • persons
  • projects
  • partners

We need pageviews for

every person

  • name
  • involved in project a,b, c
  • works for partner d,e,f
  • project coordinator in project a, b, c

every partner

  • name
  • employs persons a, b, c
  • involved in project a, b, c
  • lead partner in project a, b, c

every project

  • name
  • leadpartner
  • project coordinator
  • partner
  • persons

Here is an idea for a solution using the module noderelationships

Beside the noderelationships module you need a drupal installation and the cck, views, modalframe, jquery_ui module. I use admin_menu too.

Content types

We create a content type for each actor (person, project and partner).

Node reference fields

Now we have to setup the node reference fields for each content type

  • Partner
    field_project

    (cardinality unlimited)

  • Person
    field_project

    (cardinality unlimited)

    This field already exists, so we can use it again

    field_partner

    (cardinality unlimited)

  • Project
    field_projectcoordinator
    field_leadpartner

    (cardinality 1)

Node relationship

We can now use the node relationship module.
In the edit form of the content type you have now an additional tab Relationships.

The first impression you get is the wonderful entity relations diagramm. It is automatically drawn by the node relationsships module and shows all relations (from and to) of the content type partner.

Behind the second tab (Node reference extras) you find the reference to fields and you can configure how it should behave in the edit form of the partner content type. For reference searching you can choose a view. You can create own views by cloning the predefined noderelationships_noderef view. The cloned view will appear in the options list. In my case, I used the standard table style view. If you check the box Create and reference it is possible to create a new project and reference it from the edit form of the partner content type.

This sounds all a bit theoretical, so here is the partner edit form with the project referencefield. The users can use the usual way to find a relationships via autocompletion. The cool icons at the right side of the field are the part of the node relationsships module.

After clicking at one of these icons a popup opens. Depending on the icon, it is a list view (which you can change in the configuration) with a filter or an add form for a new project.

With these tools, it is easy to set the references.

The third and last tab are the Back reference settings. Here you configure, how relationships from other content types are displayed. In our case we have relations from the person and the project content type.

In the next screenshot you see the backreferences from the person content type.

That's it :-)

Results

With this node relationships module it is very easy to organize references between nodes. Play a little bit around and you will see, how easy it is!

The results are also visible at eu.cocoate.com.

I often have the problem to visualize relationships between nodes. Sometimes I use blocks in views with parameters, sometimes I embed views in node templates and so on. Another problem is often the kind of relationship between nodes. Sometimes they have a relationship vice versa, sometimes not. But I don't want to bother you with these things ...The reason why I am writing this entry is, that I have found a good module helping me to get my job done: noderelationships.The Task: Who is doing what with whom?We have three actors: persons, partners and projectsWe want to have a website with a few relationships

10 commentaires

great write up

Par rogerpfaff (non vérifié), le 17. août 2009 - 8:24.

thanks hagen for writing this. I think most of us where looking for a solution like this. I personally never found it... roger

Node Relationships - Stream: this post can't be referenced.

Par Guest (non vérifié), le 18. novembre 2009 - 17:34.
Thanks for the instruction. Very helpful. Tried it out on Drupal v6.14 and almost got it working. Encountered following problem. Installed and activated node relationship module and all other relevant modules. Created 2 new content types in CCK, conference and stream. The objective is to reflect a parent child relationship where a conference is the parent and may have zero or many streams. For content type:conference Created a field_stream, of type Node Reference and Widget Type: autocomplete text field. In global settings set Content types that can be referenced: to stream, View used to select the nodes: noderelationship_noderef Relationships ERD shows "Conference refers to stream". Node Reference Extras tab, Reference field: Stream, Referred types: stream, Required:No, Cardinality:1 Search and reference view:Grid Style Create and reference: checked on. For content type:stream Relationships ERD shows "Conference referred from stream". Node Reference Extras tab, Could not find node reference fields referring to other content types from Stream. Back reference settings: Conference / Stream placed in fields region. Saved all changes. Start to create a Conference. Get to Stream field which presents 3 icons (view, search and reference, create and reference.) Select create and reference and successfully create a stream "Executive Interest". Following placed in conference stream "Executive Interest [nid:7]" after completion of stream create. Return to Conference and try to save Conference but get message "Stream: this post can't be referenced." Remove content of Conference stream field and saved conference. From Conference/Stream used search and reference to locate "Executive Interest" stream. (This content was created) Click on apply but pop up still shows "Currently selected Stream: non" Keyed "Executive Interest" into Conference/Stream field but "Stream: this post can't be referenced." I appear to be close to a solution but cannot overcome this last issue.

Share Who To go here

Par links of london (non vérifié), le 14. décembre 2009 - 3:36.
For reference searching you can choose a view. You can create own views by cloning the predefined noderelationships_noderef view. The cloned view will appear in the options list

Thanks for the article. Do

Par Reda (non vérifié), le 25. décembre 2009 - 21:16.
Thanks for the article. Do you know if there is any way to change the label of the backreference "field"? The one that says "Back references from X in Y" ?

Backreferences from...

Par Guest (non vérifié), le 25. janvier 2010 - 15:04.
It's located at line 531 in noderelationships.inc. I suggest you don't alter the modules code but make a custom module for it.

it is not a shame, you're

Par onder (non vérifié), le 28. janvier 2010 - 23:12.

it is not a shame, you're perfect miss; i couldnt find this solution for months thanks a lot

Changing the label of a back reference

Par millionleaves (non vérifié), le 10. février 2010 - 3:14.
You can do this by going to the Manage Fields tab on the content type to which you've created the back reference. You should see one or more fields (depending on the number of back references you've created) called "Back references from X in Y". Click the field for which you want to change the label. You will then be able to edit the label. Note that if you then go to the Back Reference Settings and move the field to a Page or Tab then back again to Fields, the label is reset. Not sure if this is intended behaviour. Regards David

Default Views in Back References settings

Par millionleaves (non vérifié), le 10. février 2010 - 3:29.
This is one that drove me crazy for a while. When you look at the Back References Settings, you see a list of back references in the Fields list (as above). For each field, it has a "Back Reference View". Problem is, there is only one option in the list - Default. I tried editing the view and adding additional displays with different fieldsets, but that didn't give me additional views to choose from. Finally, I did as the instructions suggest and cloned the default view. Presto - the clone shows up in the list. Reason? There is a tag on the Default view that is used by the module to identify views that can be used for back references. Cloning the Default gives you another view with the same tag. Hope this helps someone out there. Node Relationships is an awesome module but it's complex and the documentation is a little light :-) David

Thanks for the article. Do

Par Aria (non vérifié), le 7. août 2010 - 11:15.

Thanks for the article.
Do you know if there is any way to change the label of the backreference "field"? The one that says "Back references from X in Y"

Regards

Thanks David, I had been

Par Guest, le 15. septembre 2010 - 18:49.

Thanks David, I had been trying to figure that out and post this post. It's a shame you have to create a whole new view though. I already feel like I have too many views.

Publier un nouveau commentaire

  • Les adresses de pages web et de courriels sont transformées en liens automatiquement.
  • Tags HTML autorisés : <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <br><pre>
  • Les lignes et les paragraphes vont à la ligne automatiquement.

Plus d'informations sur les options de formatage