Two-way node reference in Drupal 7
vih.dk is a site for a Danish Folk Highschool. The school has some teachers that teaches different subjects. A teacher teaches several subjects, and more teachers can teach the same subject. We have created both teachers and subjects as content types, and thus both teachers and subjects are just regular nodes.
We could easily do the reference using the references module. However, we wanted the relationship to be updated both when editing teachers and when editing subject. So on the teacher page, I could select several subjects for that particular teacher. And on the subject page, I could see which teachers I already added from the teacher edit page and add more teachers if needed.
That was fairly easily achieved with the “corresponding node references” module. So editing both content types, we added a new content reference field on both content types. After that we navigated to admin/config/system/corresponding_node_references and made sure that the checkbox for the relationship was checked.
Then I was ready to start editing my content. There is however an unresolved issue when using versioned nodes which I haven’t figured out yet.
However, on the edit page we now had multiple select lists, which by default is not too user friendly. The user needs knowlegde about using them, and failing to click CTRL when making a new selection will remove all other selections. Luckily I recently read a blog post about the chosen module and library. When enabled you will get very cool and user friendly select boxes where you can type in what you want to select like this.
How would you solve it?
You can be the first to add a comment below.
Leave a Comment
Din e-mail bliver ikke offentliggjort. Obligatoriske felter er markeret Required fields are marked *.