Skip Navigation

[Resuelto] Display data from one-to-many and many-to-many relationships in views

This support ticket is created hace 4 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 respuestas, has 2 mensajes.

Last updated by Christian Cox hace 4 años, 2 meses.

Assisted by: Christian Cox.

Autor
Mensajes
#1492409

Good afternoon.

First a question about many-to-many connections.
I have several many-to-many connections between post types.
For example: Archival objects - Persons. That is, any work can be associated with an unlimited number of Persons and vice versa.
I make layout for Archival objects. I was able to display on it a list of persons associated with Archival object.
But in addition I want to list other Archival objects related to Person that are related to this particular Archival object.
I don’t know how clearly I explain. 🙂

And a similar situation with one-to-many.
For example: Archival object can be in only one Collection, but I want to list the other Archival objects from the same Collection.
I can’t understand how I can configure the filter in view so that the data is displayed correctly.

P.S. Sorry for the bad English and possibly trivial questions. We have to finish the site for another programmer, and even without knowledge of English.

Sample: hidden link

#1492681
Screen Shot 2020-02-04 at 3.11.33 PM.png

But in addition I want to list other Archival objects related to Person that are related to this particular Archival object.
You can use a nested View structure to display something like this:
Archival 1
- Person 1
----Archival 2
----Archival 3

-Person 2
----Archival 3
----Archival 4

-Person 3
----Archival 2
----Archival 3

To do that, you would create a View of Archivals and add a Post Relationship Query Filter, where the related post is set by the current post in the loop. If you cannot see the Query Filter panel, scroll to the top right corner of the site and click "screen options" to activate the Query Filter editor. Then you would insert that View of Archivals inside the loop of your View of Persons. Let me know if this is what you want to accomplish, or something else.

For example: Archival object can be in only one Collection, but I want to list the other Archival objects from the same Collection.
You can do this by creating a View of Archival objects and add a post relationship query filter, where the related post is set by one shortcode attribute (see the screenshot here for an example). Set the value of that shortcode attribute using the related Collection post ID shortcode. The View shortcode will look something like this:

[wpv-view name="Your Archival Object View" wpvrelatedto="[wpv-post-id item='@collection-archival.parent']"]

This is an example of passing arguments to Views, as described here: https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/

#1496973
2020-02-06_23-17-02.png
2020-02-06_23-15-05.png
2020-02-06_23-13-43.png
2020-02-06_23-07-49.png

Good afternoon, Christian.

I will write about the many-to-many connections
That is, i need:
1) create a view to display the archived objects of a person
2) insert it into the view showing all the persons associated with the archive object
Do I understand correctly how to do it?
Image 2020-02-06_23-07-49 and 2020-02-06_23-13-43 - This is the view under item 1
Image 2020-02-06_23-15-05 and 2020-02-06_23-17-02 - This is the view under item 2
Yellow highlighted an intermediate type of posts (can it not interfere?). And my previous attempt to display the information I need.

#1497061

Regarding the second part of your instructions.
Did everything as you wrote. View even works, but for some reason only one result is displayed. No limits have been set.
Page where view is displayed: hidden link - block OTHER ARCHIVAL OBJECTS IN COLLECTION:
Real information about related objects: hidden link - block ARCHIVAL OBJECTS IN THIS COLLECTION:

Code inserted in layout:

[wpv-view name="another-archival-objects-in-collection-page-ao" wpvrelatedto="[wpv-post-id item='@location-archival-object.parent']"]
#1497063

Hi, may I log in to take a look at this in wp-admin? I think it will be faster if I can see how everything works together. Please provide login credentials in the private reply fields here.

#1500687
collections.png
objects.png

Did everything as you wrote. View even works, but for some reason only one result is displayed.
Okay I am looking at this Archival Object post:
hidden link

In the section "Connecting Archival Objects and Collections-Locations, you can see the Anna Akhmatova Autograph post is connected to one Collection, the Pushkin House:
hidden link
See collections.png.

Edit that Pushkin House post in wp-admin:
hidden link

You can see that only two Archival Objects are linked to Pushkin House. One is Anna Akhmatova, and the other is Postcard to Jane Butler from Lydia Pasternak Slater.
See objects.png

Back on the Anna Akhmatova post, you can see the Postcard to Jane Butler post appear in the View. So this appears to be working correctly. Only one post should appear here. What am I missing?

#1500841

Christian, thank you.

This is my mistake.

Tell me on the many-to-many links: https://toolset.com/forums/topic/display-data-from-one-to-many-and-many-to-many-relationships-in-views/#post-1496973 ?

#1500851

Look at this Archival Object again:
hidden link

Underneath the title Postcard to Jane Butler from Lydia Pasternak Slater you want to display all the Collections related to the Postcard to Jane Butler from Lydia Pasternak Slater Archival Object, is that correct? Here is that Archival Object in wp-admin:
hidden link
You can see that this Archival Object is related to only one Collection - Pushkin House.

So you need to create a View of Collections and add a post relationship Query Filter. Choose the Connecting Archival Objects and Collections-Locations post relationship, where the related Archival Object is the current post in the loop. In the Loop Output editor, insert the post title for now so we can test the results.

After that, place this View of Collections inside the loop template of the Another Archival objects in collection (page AO) View:

<div class="fs12 item-in-bottom-slider">
  <div><a href="[wpv-post-url]" target="_blank" rel="noopener noreferrer">[wpv-post-featured-image]</a></div> 
  <div>[wpv-post-link]</div>


  PLACE YOUR VIEW OF COLLECTIONS HERE


</div>

Now you should see "Pushkin House" appear below the Postcard to Jane Butler from Lydia Pasternak Slater post information.

#1501783

Good evening, Christian.

Thank you again for your help. I understood what to do with the collections.
At the moment, I ask you for help in displaying objects of the same author (view ARCHIVAL OBJECTS RELATED TO AUTHOR). Connecting Archival Objects and Persons-Authors relationship.
Do I have to do the same with collections?

#1502171

I'm not sure I understand. Where do you want to place this View, and what should it display?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.