Home › Toolset Professional Support › [Resolved] "Pass-through" date filter on view
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10: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/Kolkata (GMT+05:30)
This topic contains 10 replies, has 2 voices.
Last updated by Minesh 5 months, 3 weeks ago.
Assisted by: Minesh.
Tell us what you are trying to do?
I apologize ahead of time for the complexity of this one, but I am unsure how else I could accomplish what I need.
I have two views, first one that displays two custom post types (Containers, Shipments), that is named 'per-warehouse-inventory-view-p4-date-filter'.
Second one that displays warehouses but also renders the first view within it, named 'per-warehouse-inventory-p3'.
This allows me to display the Containers and Shipments that belong to a warehouse.
What I'm attempting to do now is to filter the Container and Shipment results by date. To do so, I've created a universal date field that belongs to both Containers and Shipments. I've placed a conditional on the 'per-warehouse-inventory-view-p4-date-filter' view for Containers and Shipments that looks like this:
<wpv-loop>
[wpv-conditional if="( $(wpcf-universal-confirmed-date) ne '' ) AND ( $(wpcf-universal-confirmed-date) lte '[universal-date]' )"]
<tr>
[wpv-post-body view_template="loop-item-in-per-warehouse-inventory-view-p4-date-filter"]
</tr>
[/wpv-conditional]
</wpv-loop>
The shortcode in the conditional has been registered and is grabbing the date parameter from the URL when the date filter is applied. The shortcode is working, I've tested that output and it is correct. Infact when I display just this view with the date filter search it works correctly. You can see this on page id = 1378, when manually applying '&wpv-wpcf-universal-confirmed-date=1712707200' as the date filter in the URL.
However, when I move the search filter to the view 'per-warehouse-inventory-p3', it does set the url parameter correctly, but it doesn't return any results. So the conditional on the 'per-warehouse-inventory-view-p4-date-filter' view isn't working when it's 'passed through' to the second view.
You can see this on page id = 6652.
I'm open to any help, advice, or suggestions you can provide. Like I said I'm unsure how else to do this, but I understand that I'm likely applying a search filter on the 'per-warehouse-inventory-p3' view which displays the warehouses, that doesn't apply to the warehouse cpt, and that is likely returning nothing.
Thank you kindly!
Hello. Thank you for contacting the Toolset support.
Can you please share problem URL and on what page what is your expected result and with what URL param I should test the result agaist.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
On this page:
- hidden link
I you are using nested view where the top level view is:
- hidden link
This view is set to order by post date field.
Inside the above view's output I see you have added another view:
<div class="inner-tbl">[wpv-view name="per-warehouse-inventory-view-p4-date-filter"]</div>
As you have two views - each view's order by settings are independent you can not merge them. I'm not sure yet what is your expected output.
I see the second view you created is also set to order by post date:
- hidden link
What universal custom date field you created? What if you try order by the above view (6643) to custom universal date field you created - does that helps?
Hi Minesh,
I'm not concerned with the order-by settings at all. I simply want to apply a date filter for "universal-confirmed-date" on the view 'Per Warehouse Inventory P3' (id=1382) that also applies to the nested view 'per-warehouse-inventory-view-p4-date-filter' and returns results.
Currently nothing is being returned when I apply the date filter as seen on this page: hidden link
I had the nested view's results hidden using css, but I've removed that so you can see that nothing is being returned on that page when the date filter is applied.
Note, nothing is returned when the page initially loads in the nested view, but that makes sense because the conditional applied in the nested view, which is on the loop as seen below, should only allow entries with non empty dates, and dates that are less than or equal to the 'universal date' being applied by the filter on the 'Per Warehouse Inventory P3' view.
<wpv-loop>
[wpv-conditional if="( $(wpcf-universal-confirmed-date) ne '' ) AND ( $(wpcf-universal-confirmed-date) lte '[universal-date]' )"]
<tr>
[wpv-post-body view_template="loop-item-in-per-warehouse-inventory-view-p4-date-filter"]
</tr>
[/wpv-conditional]
</wpv-loop>
I'm using the [universal-date] shorcode to capture the date field from the url parameter when applied by the search.
Hope this clarifies what I'm looking to do.
Thanks,
Matt
So lets assume - if user select today's date from the date filter available at top of the page:
- hidden link
It should show only record equal to the selected date only - is that correct? or do you have other requirement?
On that page, if we select a date and hit submit, I'd like for it to return all containers and shipments that are less than or equal to the date input.
The issue seems to be that the view "Per Warehouse Inventory P3" is applying the date filter to the warehouses as well, which then leads to it returning nothing. Is there a way to only apply the date filter to the containers and shipments coming from the nested view?
Can you please tell me with that with what date I should test the result against as I checked many containers or shipments posts but I do not see date is setup with those posts.
You can use 2/1/2024
Not all containers will have the date populated, but most should. I updated enough of them to test with.
Can you please send me edit post link of both container and shipment post where 2/1/2024 date is setup for the universal custom date field?
Here you go Minesh,
Conatiner: hidden link
Shipment: hidden link
Thanks!
I've created the following view that displays the wareshouse:
- hidden link
Created the following views:
Related Containers:
- hidden link
Related Shipments:
- hidden link
Inside above view's that displays the warehouse I've added the above view's that displays related containers and related shipments belongs to the current warehouse in the above view's loop:
<li> <h1> Warehouse: [wpv-post-link] </h1> <hr /> <div> [wpv-view name="related-warehouse-containers"] </div> <div> [wpv-view name="related-warehouse-shipments"] </div>
I've created the following test page:
- hidden link
Can you please try to apply the date search and you can see the results and compare it.
You can format the view results as required.