In my camera issue view (&view_id=7445) I have a column that displays the location of the camera which is related to the title of the camera in the first column. IOW, in the issue form, the user selects a camera and that camera has a location that it is related to already.
So we are dealing with 3 CPTs (Cameras) (Camera Issues) (TMNA Locations).
The location (TMNA Location) is related to a (Camera).
A (Camera Issue) is related to a (Camera),
However, I cannot get the location of the camera to display in my view of issues. I've tried every type of post relationship for the (TMNA Location) field I can think of and it won't show up. I have to be doing this wrong. How do I get the related location to show up automatically for the selected camera for the (post) issue in the view?
Thanks!
Hello,
How do you setup the post type relationships?
I assume we are talking about three post types:
- Cameras
- Camera Issues
- TMNA Locations
One-to-many relationship between Cameras and Camera Issues
One-to-many relationship between Camera Issues and TMNA Locations
If it is, it needs a nested view, for example:
1) Parent post view
- Query Camera Issues posts
- Filter by relationship between Cameras and Camera Issues
- In view's loop, display below child post view
2) Child post view
- Query TMNA Locations posts
- Filter by relationship between Camera Issues and TMNA Locations
- In view's loop, display TMNA Locations post information
In single Cameras post content, display the Parent post view, and test again.
Actually all the relationships are many to many.
So how would I create this nested view?
Just generate a custom view that looks at one field 'location' and then insert it in the 'parent' view?
Yes, you are right, in your case:
One "Camera post" can connect with multiple "Camera Issues" posts
One "Camera Issue" post can connect with multiple "TMNA Locations" posts
So you can try the same steps as I mentioned above.
More help:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
I created the seperate view and added the embedded view to the parent one but I'm getting no result found in the list.
I don't see anything wrong in your screenshot:
https://toolset.com/wp-content/uploads/2020/09/1770275-view_2.png
Please provide a test site with the same problem, fill your website credentials in below private message box, also point out the problem page URLs and view URLs, I need to test and debug it in a live website, thanks
Thanks for the details, I can login your website, and have done below modifications in your website:
1) Edit the child post view "Camera Related Location"
hidden link
In section "Content Selection", enable only post type: TMNA Locations
in section "Query Filter", change the filter to:
Select posts in a Camera Issues TMNA Locations relationship that are a related to the current post in the loop.
2) Edit one "Camera Issue" post:
hidden link
in section "Camera Issues TMNA Locations", connect one existed "TMNA Location":
3) Test it in front-end:
hidden link
It works fine, can you confirm it? thanks
Well, you are correct that it does work the way you set it up. But that isn't exactly what I had in mind.
The hierarchy of relationships is as follows: tmna location>camera>camera issues. Therefore when a camera issue is created and the user selects a camera, the location is already linked to the camera. So that location should be retrieved from the same place. IOW, we have:
The Camera Issue linked to a Camera which is linked to a tmna location(s). My goal is to eliminate the location field from the camera issue form altogether since we already know the location of the camera (as it's already linked in the database).
I have tried the credentials you provided above:
https://toolset.com/forums/topic/relationship-in-view-not-working/#post-1771567
But get below error message:
There has been a critical error on your website. Please check your site admin email inbox for instructions.
It seems there are PHP errors in your website, please fix it first, then update here.
Sorry luo, it was a typo in a function. It's fixed now.
There are lots of post type relationships in your website, some of them are duplicated or useless, for example:
Camera Issues Cameras:
hidden link
Cameras Camera Issues
hidden link
Please point out the correct relationships for you mentioned above:
The hierarchy of relationships is as follows: tmna location>camera>camera issues
Which post type relationship is for "tmna location>camera"
Which one is for for "camera>camera issues"
To avoid more misunderstandings, please elaborate the questions with more details
Which question did you have?
Please point out the correct relationships for you mentioned above:
The hierarchy of relationships is as follows: tmna location>camera>camera issues
Here are my questions:
Which post type relationship is for "tmna location>camera" ?
Which one is for for "camera>camera issues"?
Please point out the correct relationships URLs
Sorry, I guess I didn't understand your original question.
The hierarchy is as follows:
TMNA Location> Cameras > Camera Issues
Each Camera is mapped to a TMNA Location so (in theory) when a Camera Issue is entered an a Camera is selected the location should appear automatically because it's related to the Camera.
Camera is related to one (or more) TMNA Locations. camera-tmna-location
Camera is related to one (or more) Camera Issues. camera-camera-issue
I hope this makes sense.
Hi,
Luo is on vacation, so I'll be following up on this ticket shortly, after understanding the full context.
Thank you for your patience.
regards,
Waqar