I need some help setting up a filtered view - I have tried and failed - most views on our new web site are working - this one is problematic as it need
for each event we need to filter on values specific to the event
So ...
places_sold_for_this event = maximum_places_for_this event - places_available_for_this event;
if (places_sold_for_this event => minimum_places_for_this event) {
// Costs are covered
if (places_available_for_this event > 0) {
// But we have some residual places remaining
if (startDate_for_this event > Today && startDate_for_this event > Three_months_from_now) {
// The event starts beyond today, but within three months
// Show the event with a 10% discount
}
}
}
Example page at lien caché
I cannot work out the filter for doing this - mainly because a number of the variables are dependent upon the current record in the loop
Or are filters the wrong way to approach this - and I should be using conditionals - that I also tried - but failed on that score miserably
Hi, I'm having trouble understanding the logic here. Is this the only result that should be displayed in your View? If not, please provide some more information about the nested "if"s.
// Show the event with a 10% discount
Conditionals can be very useful if pagination is not required. If pagination is required in the View, conditionals can cause some minor problems. For example if you want to show 10 results per page, but a conditional hides 2 of those results, your View will only show 8 results on the page. In the next page of results, it may only show 3...so it looks inconsistent from page to page.
To filter on values based on the current element in the loop, you could use shortcode attributes and nested Views. This technique is called passing arguments to Views.
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
All three of the IFs have to be met - then event information is output to the page - yes - pagination is not required
So the logic is have I sold more than the minimum number of places for this event AND are there some places remaining available AND is the event starting within three months of today - then display the event - ELSE this event is not displayed
Okay thanks, I understand more clearly now. I think you'll need a combination of Query Filters and conditional HTML.
if (places_sold_for_this event => minimum_places_for_this event) {
I don't know of an easy way to filter a View by comparing two custom field values like this, so I think this part is best accomplished as a conditional statement in the Loop of your View.
if (places_available_for_this event > 0) {
This part can be handled easily with a Query Filter testing this custom field value as an UNSIGNED value greater than Constant 0.
if (startDate_for_this event > Today && startDate_for_this event > Three_months_from_now) {
This part is best handled as a Query Filter. Add a filter on this start date field as an UNSIGNED value between Constant FUTURE_DAY(1) and FUTURE_MONTH(3). I'm attaching an example here.
So all together that's two Query Filters and one conditional statement. You should be able to build the conditional directly in the loop of your View using the conditional HTML builder. Let me know if you have questions about that.
Well that certainly taught me a lot about toolset - I think it now works
lien caché
There's a real mix of conditionals and filters in there - but it pretty much displays the right records now
Now I just need to get the 10% discount shown and the specific booking form
But those are easy now I am showing the correct records
OK that's great news. Feel free to set up separate tickets if you need additional assistance with those forms and discount displays.