Preview for Many-to-Many Relationships in Toolset
The last piece of our post-relationship project is getting done now and we’re very close to a first public version. In this preview, you can see how to set-up many-to-many relationships and how to connect the related posts.
Our demo site includes doctors and patients. Ideally, a patient will never have to see a doctor. But just in case it’s needed, you can create the connection between them with Toolset.
Any doctor can see a number of patients and any patient can visit a number of doctors. Therefor, we need to set-up a many-to-many relationship between the two types. The natural connection is ‘visit’ (what you’d call a ‘doctor visit’). A visit has its own fields. For sure, a visit needs to have a ‘date’.
The last part that we need to build is the query filter in Views. When you work on a template for doctors, you need to be able to load the connected patients through the visits. You’ll be able to filter visits, display their information and the information of the visiting patient.
When
We’re going to offer a first public version (not for production yet) by the end of this month (September, yes 2017). Shortly after, we’ll also have a version of Views with the corresponding filters for the ‘many’ relationships. CRED will follow soon after.
The date for the production version depends on how well the beta versions will go. If we do our work correctly, there shouldn’t be a big delay between the development and production versions. If we understand that we did something completely wrong, we’ll need to adjust.
Feedback?
We already got a ton of valuable feedback for the previous demo videos. Your feedback was very important in identifying missing/wrong features and correcting them quickly. I hope to get good feedback and great ideas for this preview.
Leave your comments here and we’ll get back to you.
The imminent availability of many-to-many relationships is very exciting; I’ve been waiting for this for several years now. I build websites for horse farms. A horse may have several offspring, and every horse has two parents; clearly one valuable application of this functionality will be in the building of family trees. Can I participate in the beta testing?
We’ll have a public beta (available to all Toolset clients) by the end of this month.
Actually, for horses and their offsprings, this version may have an even better match your you. You will be able to define several one-2-many relationships between the same post types.
For example:
(Father): horse->horse
(Mother): horse->horse
This isn’t currently possible with Toolset, but will be available in the post-relationship project (this month).
I haven’t seen the previous videos on this, I’ve really missed out. This looks great and is ideal for something I’m working on so I can’t wait to see it. Is there an inbuilt option to not have columns displayed in the admin back area? Right in that last frame it was annoying to see the lorem ipsum short bio column.
We need to offer which columns to display in that table. I’ll make sure that we have it in the development list (if it’s not implemented yet). Thanks for the good catch.
Ok, looks great. One question springs to mind because of a current woocommerce project. Can this be used to create a relationship between a product and custom post type? So in your example, a relationship between doctors and any medication currently on sale in the site shop?
The WooCommerce products are CPTs, so it should work out-of-the-box. You’ll be able to connect Products with any other post type in your site (like doctors and products).
This will be a game changer! Is the team still on track to have a beta by the end of the month?
Yes, will be ready this week.
Thanks, all sounds good!
Excellent demo, pretty excited. Keep up the great work (Y)
Looks good. We can finally dump the unsupported posts-2-posts and create a post relationship that doesn’t involve a parent/child link… right?
This feature in Toolset will cover everything you need for post-2-post relationship (and some more).
I’ very exited about this. Can’t wait tot do a project with this.
Doctor visit example – dates
In the example you have given, you have described very well the use of many to many. One thing I set to be looking for is the use of dates or calendar type filter.
A doctor will like to see what patients ate coming for visits per day and week. So it will be needed to have a way to filter that view of visits for all the patients.
I am working on a project that will actually need a full many to many relationships. So the upcoming beta will be used in quite a progressive way. I will outline the use case in the next reply. I look forward to your reply regarding filtering the patients visits by day/week/month type scenario.
What you’re describing will be possible in this version of Toolset. The ‘visits’ are a CPT with their fields. You’ll be able to set up a Custom Search (with Toolset) for these visits. Then, you can display both sites of the related content. I’ll include your contact details in the ticket where we add the related data to the Views filters. We’ll follow the scenario that you described and then send you an early development version to see that it’s what you mean. Sounds OK?
Hello, I’m interested in this feature. We are a music festival and we have events in that are scheduled with real date (toolset date/time field) but when we show them in the schedule we new to show for a day the events scheduled from 1 pm to 7 am (next day)… Can this be done with the new many to many?
Right now, we are setting up the post relationship but not making changes to the date/time filtering. Are you running into a limitation with that filter?
Maybe just I’m not understanding how to filter… or maybe is not just a filtering problem. A day normally starts (and ends) at 0.00. In the festival a day starts at 13pm and ends at 7.00 am (next day)… so when a user select a day I need show the events scheduled this day from 13pm to 7am (next day) … Do you think this could be achieved with the current date filtering? If yes I will open a support ticket to understand how to set up the filters.
Thank you for your attention Amir
I see now. Thanks for the explanation. I’m not sure if it’s possible or not. Can you create a ticket, paste its URL here and I’ll refer it to the right developer?
Here the support link: https://toolset.com/forums/topic/when-i-filter-a-day-i-need-to-show-events-from-13-pm-to-8-am-next-day/#bbp-new-topic
Is it also worked out in views and creds?
It will, very soon. This month we’re completing the integration with Types, which is the biggest part of this project. Then Views and then CRED. The production release will include full support in all of Toolset and in WPML.
This looks great. In the past I had to create a pseudo-relationship based on the authors when I needed to connect sermons and preachers on one site; this new mechanism would have been a better approach.
Keep up the great work. I look forward to testing this out.
Exactly. Now, you can define it directly. The direct m2m relationship is easier to setup and a lot more efficient to display on the front-end.
Looks good but how well will this scale? Do you plan on adding filters in views for this? Will CRED allow us to have front-end forms with such relationships?
How fast would this be for 100.000 posts, including filtering?
Yes, we’re implementing this in all Toolset plugins, including Views and CRED.
Doing a DB-search with MySQL between 100K records can work, but it’s not going to be fast. It’s not about Toolset, but about MySQL and it really depends on the frequency of searches and your expectations.
To give you an example, there’s a search in our forum. We could theoretically use the WordPress built-in search, but we wouldn’t dare. Instead, we’re using Solr search, which returns instant results. Of course, setting up this Solr search took us weeks of development.
So, it really depends on what you expect and what you’re willing to invest.
Does this help?
Using object caching like Redis, can improve DB search or DB queries, since the second time a request is sent, it is being sent from Redis and not hitting MySQL. Elasticsearch is also something that could help.
ElsaticSearch and Solr are very similar. In fact, we’re moving the heavy searches in our sites to ElsaticSearch. We’ll see if there’s a way to hook between Views and ElasticSearch, but it’s not going to be a trivial project.
This will be a great feature and will make the relationship better than now, many 2 many leak at the moment, great job!
This is great. I’m impressed by how the many-to-many set up is handled in GUI. With these updates, Toolset will become much more useful and powerful. Can’t wait!
Nice video. Thank you. I”m looking forward to testing it. A few things came to mind:
* Can you add categories and tags to the relationship CPTs? So you could mark visits as per their type: Consultation, Pre-Operation, Post-Operation, Checkup, etc.
* Just brainstorming: Suppose the doctors have specializations and one doctor ‘Refers’ a patient to another doctor. In this case, the doctors’ have many to many relationships, so how do you show more than one of those on the edit screen? Are they just stacked? Presumably, doctors could refer patients to each other, so the relations could go both ways. How would that be shown on the backend?
* It might be worth exploring the ability to show the child CPTs (the relationship is a CPT) nested under the parent in the WP Admin, instead of at the bottom of the parent edit screen. Justin Tadlock did this for his Message Board forum software, an alternative to BBPress. It is so much nicer.
* in less than a month, there would be too many ‘Visits’ and the bottom of the doctor’s edit screen wouldn’t work. After a year, hitting the sort arrow would slow the whole system down for all of the users.
* When you hovered over Abby (the patient) there was not an option to ‘View’. Would that make sense?
Thanks for the feedback David.
The intermediary post is just a post. You can use anything in WordPress for it. The m2m connection is a bit of a hybrid. The actual post connection will happen via a dedicated, efficient and invisible table. The ‘connection meta’ will use its own post. So, you can attach anything to that post and it doesn’t affect performance.
Each relationship has a name now. It’s not just ‘many-2-many’, but by name. You can see this in the video that I produced. In my example, it’s a “visit”. You can set up as many relationships as you need, including between the same types.
Can you help me with a screenshot of the nicer display you’re mentioning?
There’s pagination and search for the relationship. It’s not going to inflate the single-doctor display beyond the maximum set for pagination. The pagination works with AJAX and is actually pretty slick. There was a ‘view’ for the patient. I just clicked on the wrong button and pushed the browser ‘back’ instead of ‘click’.
Sounds good. This is a different forum plugin where the CPTs are displayed hierarchically. Not sure if that works for relationships or not.
https://cl.ly/153u1I230N0i
i also join in to thank you for this very useful feature.
Is there going to be a drag and drop reorder or something like that? This looks amazing but reordering posts has historically been very painful…
Drag-and-drop reordering is not so simple. For example, if you create connections for doctor-appointments, what would you order by? The natural ordering is by appointment date. Do you want to change dates by dragging?
Drag-and-drop makes sense when there’s one criteria to order by. Pages are a good example for it. When you’re talking about m2m relationship, remember that the same item will belong to many others. I’m not sure what you would use as the ordering key.
Hey Amir- yes I would expect that to be a problem in a many to many relationships, but was hoping that we would have the option to drag and drop sets of repeating fields set (similar to how you can do this with a single repeating field today) in one to many relationships.
Amir!!!! Wow.. You guys sure didn’t disappoint on this project! This looks absolutely amazing. I’d even venture to say it looks like it was worth the wait! 😀
Thank you so much for all you do. I’m very much looking forward to implementing this into my workflow.
Cheers!
Jay
And thanks for your feedback 🙂
Hello,
I understand the new many-to-many relationships will allow to create relationships between same post type, which is a must have feature. Thank you for this.
My question is about the transition between the old many-to-many relationship system and the new one. I have several sites with many-to-many relationships based on parent/children post types. What will occur with them ? Will the relation still work ? Must I update those relations ?
Also in views, I think it is necessary to allow front-end filtering by several post relationships, including by grandparent. For instance I can have :
Professor >> Studies <> Treatments << Patients
And would like to show a view displaying all Doctors with both a Professor and Patient front end parametric search filters.
And I must also be able to setup a view displaying all Patients with a filter by professor who teached at least one of the patient's doctors.
Will all this be possible thanks to new relationships system ?
Thank you.
We’re creating automatic migration between the old one-to-many to the new one-to-many. We’ll try to create the same for m2m, but I’m not sure that it can be fully automated. This is because each client implemented it a little differently. We even documented two options for how to do this. If we manage to create the content migration, you will definitely need to recreate the Views and templates that display the related content because the new arrangement works completely different.
Old one-to-many migrates seamlessly without any changes from your side.
Views will support front-end filtering for related content. Today we already offer nested filtering and this will continue in the updated design.
Views will allow you to display related content, including both via one-to-many and many-to-many.
Dear Amir,
Really excellent news,here a few things it may deserve your attention:
1. We hope that Layouts it is not out of the equation and also will be part of the enhancement to make it more flexible and user friendly.
2. We assume with the new M2M we have bility to edit the CRED forms after submission and saved partway to be completed in stages like a workflow system which is very useful feature with ( PDF printing capabilities for example generate invoices).
3. Will you able show drag and drop the processes in the workflow design area to represent any CPT field dynamically.
4. Can add to the custom roles management a place to design and control client area with login logout management.
5. Can you introduce the dynamic columns hide button like the (screen options) in wordpress admin area.
6. Hopefully WPML development team part the M2M process.
With Thanks,
Thanks. To your questions:
1. Layouts plugin has nothing to do with the relationships. When you display fields and Views (including via Layouts), you will see the relationship controls and you can choose to display related content.
2. Yes, CRED will have full support for related data. You will be able to create and edit post relations with CRED forms.
3. Not sure I understand what you mean. Maybe you can give an example?
4. You can already today create custom roles with Toolset and build log-in forms. You can see it here:
https://toolset.com/documentation/user-guides/cred-training-course/part-7-building-account-page-login-form/
5. You will be able to choose which columns to display for related content.
6. Yes, this will all be integrated with WPML as part of the production release.
Is it possible to nest M2M
Items can have relationships from different directions. However, in the GUI, we can only allow to directly set up one relationship between two posts. Of course, you can set up as many relationships as you want and achieve a chain of relationships.
Awesome
Very interested in this, I have setup a website using parent/child relationships- Bands and Players linked by Registrations and am always hate updating in case in breaks. How difficult will it be to transfer existing data into this new relationship.
Not difficult at all. Types will automatically migrate your relationships from the old parent/child to the new tables.
Very nice feature update. I have one question:
1. will it be possible in views to add a way to display siblings with the same parent. Following the video example, sibling treatments with the same doctor and patient. In this way it would be possible to list views as “other treatments with this doctor” or “other treatments done by this patient”
Thank you Amir
Yes, it’s possible even today and we’re doing it on our own site. Have a look here for how it works:
https://toolset.com/documentation/user-guides/displaying-brother-pages/
Where can I download a version of types that supports relationships? I have an immediate need for a site I’m working on, beta would be fine
We’re working now to complete a beta. It will be ready in about a week. Please note that this Types beta will still NOT be integrated with Views. This is coming next.
Ok, I don’t plan to use Views on this particular site so that’s fine. It would be great if I could get an early look…
I can´t believe it thats coming at the 01.10. And what about views. We get it than at 01.11. ?
thanks for help
Any update on the release date. We could use this plugin right away
We’re closing last things for Types beta that has post relationship and it should be ready by the end of this week (but not today). Besides the beta, we’re also preparing a quick documentation page.
Can we get a beta release to test with today?
Looking Forward to this! I have a major project I have been putting off until I could try this out.
Me too!
Wow! You guys are really keeping us in suspense! There’s only two days left in September. The build-up to this has been HUGE 🙂