Skip Navigation

[Resolved] Calculations in filtered views – How to use the same custom filter options

This thread is resolved. Here is a description of the problem and solution.

Problem:

The customer reported that there are two views on a page that are using some custom shortcode to show a count from the results, but only one of them updates correctly when the search fields are used.

Solution:

Guided that results were not getting updated in the second view because there were no query filters added in it.

Suggested to add query filters in the second view too so that they match the URL parameters used by the other view.

Relevant Documentation:

n/a

This support ticket is created 2 years, 3 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by fabianT 2 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2249501

Hi there,
I am doing some calculations with custom fields as described here:
https://toolset.com/forums/topic/make-additon-with-toolset/

with [add-to-total] and [show-total] wich works fine as you can see in this example:
hidden link
The table at the top (Gesamtstrecke, Tagesetappen, etc.) are just sums of custom fields of the custom post types below. To get this working I used a paged where I put some views together:

<div class="table-1">
<table width="100%">
<thead>
<tr>
<th style="text-align: center;" align="left">Gesamtstrecke</th>
<th style="text-align: center;" align="left">Reifenpannen</th>
<th style="text-align: center;" align="left">Anzahl der Tagesetappen</th>
<th style="text-align: center;" align="left">[fusion_tooltip title="Berechnungsgrundlage / Basis: 23,8g pro Liter Benzin / 100km | Fallbeispiel: PKW verbraucht 8 Liter Benzin auf 100km" class="" id="" placement="top" trigger="hover"]CO2-Ersparnis[/fusion_tooltip]</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;" align="left">{!{wpv-view name='gesamtkilometer' cached='off'}!}</td>
<td style="text-align: center;" align="left">{!{wpv-view name='gesamtpannen' cached='off'}!}</td>
<td style="text-align: center;" align="left">{!{wpv-view name='gesamtetappen' cached='off'}!}</td>
<td style="text-align: center;" align="left">{!{wpv-view name='gesamtco2' cached='off'}!}</td>
</tr>
</tbody>
</table>
</div>

My question:
This works perfectly fine as long as I don't use any custom filters. Can you show me a way to apply the filters I applied to the grid in the main loop also to all the views I am using to calculate the sums?

In other words: If I filter some entries, the sums should also only calculated with the filtered entries.

Thank you very much in advance.
Theo

#2250463

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Theo,

Thank you for contacting us and I'd be happy to assist.

I checked the page, but couldn't see any filter for the custom fields. Can you please share temporary admin login details, so that I can see how this is set up in the admin area? Also, include the details of how and when it is working and when it is not.

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2251415

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access.

I noticed that two views were used on the page to show the total counter using the "[show-total]" shortcode:
- PL Grid
- Gesamtgewicht

But, because the search filters were only included in the view "PL Grid", when the search filter was used, the filtering of posts would only occur in this view, but, not in the "Gesamtgewicht" view.

I've added the taxonomy query filters in the "Gesamtgewicht" view so that it is linked to the same URL parameter used by the search fields of the view "PL Grid" and now the search filters are applied to both the views.
( screenshot: hidden link )

Result screenshot:
hidden link

#2251809

My issue is resolved now. Thank you very much!

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