Skip Navigation

[Resolved] Nested Views – many-to-many relationship – Custom Search

This support ticket is created 4 years, 11 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by Shane 4 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1501979

I am trying to:

I have three views, two of them are nested inside the first one. I'm trying to filter and display information based off of a hierarchical relationship as well as a relationship using Toolsets built-in functionality.

- 1st view (parent view):
Uses post type "Services".
It has the 2nd and 3rd view nested inside using conditions to display.

- 2nd view (child view):
Uses post type "Services", but as a built-in post type hierarchical relationship.
This view works as it should.

- 3rd view (child view):
Uses post type "Attorneys", and has a many-to-many relationship with the "Services" post type.
This view DOES NOT work as it should.

Link to a page where the issue can be seen:
hidden link

What I expected to see when searching for a service:
All relevant services related to the search term, all services that don't have children, and all attorneys that are in a relationship with the services that were returned from the search.

Instead, I got:
When searching for a service, you'll see that it returns the relevant services in relation to the search term, as well as all the services that don't have any children services using the 2nd view. The attorneys view works correctly as far as showing a list of the attorneys, but the list of attorneys should only be the attorneys that are in a relationship with the service that was searched.

#1502157

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

Thank you for getting in touch.

Would you mind allowing me to have admin access to the site so that I can check on the view for you ?

This was I can check the relationships to see if they are correct on the 3rd child view.

Thanks,
Shane

#1503509

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

This view here
hidden link

It is still set to display Services rather than Attorneys, Also the filter you need to add is a Post Relationship filter and then select the correct relationship.

I'm assuming you want to list out the respective lawyers for the particular service correct?

Thanks,
Shane

#1503599

We have tested that view (services-no-children) and it works as it should on prod. The only view that's having issues is titled "Attorney-card-search-results".

We only want to show attorneys after something is searched. The only Attorneys that need to show when something is searched are the Attorneys that are related to the returned Service that was searched. Some of the attorneys are returned, but we want any attorney that is related to the services displayed in the search results to be displayed.

For example. If I search for "corporate" I get three main services listed, Corporate & Transactional, Government & Internal Investigations, and Administrative & Regulatory Investigations. I need all attorneys related to these three services and the subservices of Corporate & Transactional to be displayed at the bottom of the search. How would i go about this.

If you need the see the attorneys that are linked to the services, you can simply click into a service as they are displayed in the sidebar of the service's single page.

#1503791

Hey Shane,

We did a lot of work on production so I updated staging so you have an up-to-date version. I linked you a new PW.

The problem still persists with the search and everything I mentioned in my previous response.

Thanks!

#1504075

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-02-11 at 3.42.10 PM.png

Hi Alexander,

Based on what I see the issue is with the filter.

I'm not exactly sure what you want to filter for. See Screenshot.

Based on what I see you are filtering the Attorney Card Search Results view with the Services view search bar correct?

However I'm not sure what related information should the Attorney Card Search Results view be displaying.

Is it that it should display the attorney's that are related to the service that was searched for ?

Please let me know.
Thanks,
Shane

#1504145

1.) Based on what I see you are filtering the Attorney Card Search Results view with the Services view search bar correct?
Somewhat... the search currently works as it should in terms of showing the service results relevant to the search term.

  • If a service has child services, it shows the main service UI. The background img, sub category (child service) etc.
  • If a service has no children, it shows the card UI underneath them. The title, excerpt, and "learn more" button.
  • If anything was searched, and it returns a service, the page layout should remain as it currently does, but now it should show a list of all the attorneys that are in a relationship with the returned service. The attorney img, name, call/email , etc
  • If nothing is searched, the "Attorney Card Search Result" view should remain hidden.

2.) However I'm not sure what related information should the Attorney Card Search Results view be displaying.

  • The "Attorney Card Search Results" view should only display the Attorneys that are related directly to the returned list of services that were searched for.

3.) Is it that it should display the attorney's that are related to the service that was searched for ?

  • If you search for a service and there is only one service result, it should display all Attorney's that are related to the returned service.
  • If you search for a service and there are multiple service results, it should display all Attorney's that are related to the returned service's.
#1505915

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

Ok so we are able to filter based on the returned results.

Except here
"If you search for a service and there are multiple service results, it should display all Attorney's that are related to the returned service's."

This will only work if we are adding the view below each post. So each result will return their related attorney under it.

Currently what you have is a list of post and then you want to display the related attorneys to all those post at the bottom of the page.

However we are required to have the Attorneys display as the post is looping.

Thanks,
Shane

#1515211

I've been reading up on the Toolset Relationship API documentation since we're going to have to custom build this. Everything I've tried so far with just getting the relationship data to display has failed. How do I write the query for the relationship data and display Attorneys related to a service?

#1515343

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

For clarity are you referring to having the attorney's displayed under each of the related posts being displayed?

Example
Post 1
- Attorney A
- Attorney B

Post 2
- Attorney C
- Attorney D

Please let me know.

Thanks,
Shane

#1519411

Hey Shane,

When a search is made, we're trying to display all the posts that are related to the search term, then underneath that it will show a list of all the attorney's related to those returned results.

Example:
Services
- Post 1
- Post 2
- Post 3
etc..

Related Attorneys
- Attorney 1
- Attorney 2
- Attorney 3
etc..

Thanks!

#1519547

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

Thank you for the clarity.

Your type of list cannot be generated since the Attorneys view is generating its related data by the current post that the parent view is listing.

The way you have it in your example would require that your attorneys view be its own individual view without a parent view. This is not possible since no parent post data will be passed into the view to determine which attorneys to list.

Thanks,
Shane