Closed therealpecus closed 4 years ago
never mind, I figured it out. I'll close this.
Hi @therealpecus - any chance you could share your wisdom here? I'm pretty new to Craft (and rusty at PHP), so I'm having trouble intuiting how to use this. Thanks!
The reverse relation plugin allows you to construct a bidirectional reference between a field and ENTRY fields.
Let's say you have a section with entries that describe products (sectionProducts
) and a section with entries that describe family of products (sectionProductFamilies
). You want to be able to see the product family from the product, and the child products from the product family.
Here's how you would do it:
productsOfThisFamily
. Set the source to the sectionProducts
, then add this field to the sectionProductFamilies
sectionproductFamily
, and set the source to the sectionProductFamilies
section. Set the target field to the field you created in the previous step, productsOfThisFamily
. The other field options are fairly self-explaining.Now, when you edit a productFamily
entry in the control panel, you'll choose the products (as entries) that belong to it through the productsOfThisFamily
field. When you edit or display a product, you'll see the product family/ies it belongs to in the productFamily
field. If you did not check the read-only field, you can also edit them from within the product itself.
Thanks so much @therealpecus - that's hugely helpful.
A follow-up question for you - does it matter which 'direction' the initial entry field is pointing? That is, do you need to define the child collection field on the parent as in your example, then reverse-relations reverses it to give you a parent field on each child? Or can it go the other way, too: set the parent field on the child and then reverse-relations gives you a children collection on the parent?
Update - works in both directions, thank you! I'll submit a PR to include a summary of this info to the README if you don't mind me stealing your work?
Thanks again!
Hello,
I'm looking for minimal information as to how to use the plugins when setting fields in craft. What I am trying to achieve:
productLine
field (of type Entries) that points to the productLine entriesWhat is the field setup needed to achieve this scenario? Once I get a handle of how the plugin works i can contribute a tutorial or extended README
thanks!