Migu Posted October 23, 2021 Share Posted October 23, 2021 hello, I'm pretty new to processwire but what I've done so far is really great! What I do not quite understand yet, how can I make many to many relationships. Thanks for an answer. Link to comment Share on other sites More sharing options...
Jan Romero Posted October 23, 2021 Share Posted October 23, 2021 Hi, welcome to ProcessWire! A page reference field IS a many-to-many relationship. Say you want to model Students and Courses: each Student can enroll in many Courses, each Course can have many Students. You put a page reference field in your Student template and make multiple Courses selectable. Now you can get all Courses a Student is enrolled in: $studentPage->courses And all Students enrolled in a Course: $pages->find("template=student, courses=$coursePage") A feature that is often requested is the ability to edit or at least view this relationship from both sides. In my example, the Admin area will only show Courses while editing a Student, but when editing a Course you can’t see its Students . There are Modules that fix this, such as this one by @Robin S: https://processwire.com/modules/connect-page-fields/. It will synchronise two page reference fields so the relationship will actually be stored from both sides. 4 Link to comment Share on other sites More sharing options...
Zeka Posted October 23, 2021 Share Posted October 23, 2021 Also worth to mention 'owner' selector https://processwire.com/blog/posts/processwire-3.0.95-core-updates/ 6 Link to comment Share on other sites More sharing options...
Migu Posted October 23, 2021 Author Share Posted October 23, 2021 Thank you very much for the answers ! ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now