Jump to content

Two way page field relationship


Peter Knight
 Share

Recommended Posts

I have template for Chocolates. I have a template for Boxes. Ok, not really, but it's way more interesting to explain it this way than my real template names and purposes. :)

Anyway, my client has been creating Chocolates and building up a database of many different Chocs.

After creating a bunch of chocolates, she then creates a page called Boxes. A PageSelect field is used o select the Chocolates to be included in each Box. It works great and you've probably done the same for staff and companies etc.

That's been the process for a while. Create chocolates first. Then create Boxes and select chocolates to be added.

Now my client has come back with a curve ball and said she wants to create a Chocolate and from this page, send it to a Box.

She then wants to edit a Box and see which chocolates have been assigned to it.

It's kinda like a reverse of what we have but more importantly, there's a 2 way relationship going on where each template has a PageSelect field which is syncronised across both.

This is all in the admin BTW, we're not talking about selectors or front-end display.

Having looked around the forums, there's a few requests and a few DIY modules but they're all quite old.

Are there any plans to make official support for this or what's people experiences with the existing Modules?

Link to comment
Share on other sites

I've not used any of the modules around the forums for this but would recommend trying something like Soma's solution about halfway down in this topic: https://processwire.com/talk/topic/1071-page-fieldtype-two-way-relation/

You'll need to hardcode the two fields you want to "sync" but this also explains the problem actually - you can't just have the same field at the other template automatically as you might want to put it in certain place and label it differently etc (makes sense since its doing the reverse in the other template).

I'm not sure there's a more sensible way than Soma's module as otherwise it has to make too many assumptions whereas his is basically a case of creating two page fields to lookup the relevant pages in each template and syncing them with the module when a page using either template is saved.

Hope that makes sense?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...