Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

So, for example:

Say I have two sections:

- Recipes
- Ingredients

Recipes can have many ingredients. Ingredients can have many recipes.

If I'm editing a Recipe, I can edit the ingredients. This updates the relationship so that when I edit ingredients it can show the associated recipes (and they are editable from the ingredients as well).

Is this possible with Craft?

Thanks!

====== EDIT ======

Just to make this more clear. What I'm trying to do is create a Many to Many relationship between two Sections of Entries so there is an association between the two that works both ways.

Another example of this would be if you have a User with many Roles. I can manage which Users belong to which Roles from the Roles section, and/or I could manage which Roles a User belongs to from the Users section.

share|improve this question

2 Answers 2

You can assign ingredients to recipes using the built-in Entries field type.

Then, to view which recipes an ingredient is used on, check out the Introvert plugin. It gives you a new field type that can be used to simply show reverse relationships, also providing links to edit those other entries.

share|improve this answer
    
Thanks for the Response Brandon. This is about half way there. The client has requested the editing be a two way street, meaning that they be able to add and remove associated recipes from the ingredients edit screen. This is beneficial because say they were to add a new ingredient, they can quickly associate it with all applicable recipes rather than having to open each individual recipe and add it there. –  Peter Tell Jul 1 at 22:13
1  
Ah, yeah. Currently that’s not possible with Introvert. Feature request! –  Brandon Kelly Jul 1 at 22:16
up vote 5 down vote accepted

There's still a few kinks to work out, but I developed a plugin that solves this problem using Craft's native Many to Many relationship that already exists.

Basically, I've created a field type that links the relationship from the other side of things and allows you to add entries to it.

You can find it here: https://github.com/page-8/craft-manytomany

Thanks @Brandon Kelly for the help and guidance.

share|improve this answer
2  
Great Peter, nice work! Go ahead and submit that to Straight Up Craft, if you haven't already... I'm sure others would find it useful as well! :) –  Lindsey D Jul 12 at 23:34
1  
Good call Lindsey. Done and done. –  Peter Tell Jul 13 at 1:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.