Skip Navigation

[Resolved] Filter child views

This support ticket is created 6 years, 9 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Nigel 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#627140

Hi there, I've three posts types: A, B (child of A) and type C (child of B)

A->B->C

I've to print all the posts C given their grand father A. To achieve this I've made two views: one printing all C type given their father B and another view printing all B type given their parent A. In the content template of this second view I call the other view.

Doing this way given an A post I can print all its children and children of its children.

Now I'd like to filter by a field of C type with just one filter form that filters at the same time all the B->C views I've foreach A->B children, how could I do that?

Is there another way to display and filter descendants C posts from a certain A post?

e.g. select * from A join B join C where c.date="filter"

#627314

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Marco

The new versions of Types and Views with enhanced post relationships will expand the abilities to filter one post type by fields of connected posts which is currently not possible, but I'm not sure even that helps you here.

The only solution I can think of is to set up your nested Views with the same query filters where the value comes from a URL parameter.

You insert the filter controls with the outermost View, and then manually add the same query filter to the other Views without inserting the controls themselves.

For this to work you must use page reload rather than ajax to update the results, so that each View reacts to the URL parameter.

#628262
filtri.PNG

it's what I've done, but there is something wrong.

I've placed string filter in the outer view, and a filter (descr) in the inside views and works.

I made a between date filter and that instead doesn't work:

here the url I've upon submit /certificati/?descr=&wpv-wpcf-data_min=1520035200&wpv-wpcf-data_min-format=F+j%2C+Y&wpv-wpcf-data_max=&wpv-wpcf-data_max-format=F+j%2C+Y&wpv_view_count=73-TCPID77CPID28&wpv_post_search=&descr=&wpv-wpcf-data_min=1520035200&wpv-wpcf-data_min-format=F+j%2C+Y&wpv-wpcf-data_max=&wpv-wpcf-data_max-format=F+j%2C+Y&wpv_filter_submit=Invia

on the outer view I've theese filters:

</div>
<div class="col-sm-4">
<div class="form-group">
<label>[wpml-string context="wpv-views"]Dal[/wpml-string]</label>
[wpv-control-postmeta type="date" url_param="wpv-wpcf-data_min"]
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>[wpml-string context="wpv-views"]Al[/wpml-string]</label>
[wpv-control-postmeta type="date" url_param="wpv-wpcf-data_max"]
</div>

please find the attached pic of the inner view filters side

What's wrong?

#628633

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Marco

It's not easy for me to see why this isn't working from the above alone, it would be helpful to see your site and examine the set-up directly if that's possible.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.

Can you confirm the which page you have added the Views to.

#629080

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Marco

I checked your set up and have been experimenting on a local test site to see if I can get this working.

It works okay on the initial submission, but modifying the filter values and re-submitting doesn't work because multiple copies of the same URL parameter keep getting added each time.

I'm trying to find a way of preventing that, I'll update you again with my findings.

#629101

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Marco

I looked at ways of preventing the URLs from being appended and couldn't get anything to work, so I consulted with the lead developer and he said that it is not possible and that what I suggested—moving the filter controls from one View to another—is not supported and will not work because each View has a unique fingerprint to prevent just that.

So, I'm sorry for having encouraged you to try that. I expected that it would work but, as we have found and is confirmed the the developer, it doesn't.

I don't have any alternative for what you are asking, it's not possible I'm afraid.

#630920

So is there no way to filter a post by its grandfather? and also by some fields of the post itself?

#630997

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Currently no, that's right.

The Types 3.0 and accompanying Toolset updates will make it possible to filter posts by fields from related posts (including indirect connections such as grandparents), although filtering multiple Views using a single filter control form is not part of the update.