Skip Navigation

[Resolved] When I filter a day I need to show events from 13 pm to 8 am (next day)

This support ticket is created 6 years, 7 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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 3 voices.

Last updated by ROTOTOM 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#570276

Hello, I'm wondering if this could be achieved with views and toolset date/time field.

We have a music festival. A day normally starts (and ends) at 0.00. In the festival a day starts at 13pm and ends at 7.00 am (next day)... so in our schedule, when a user select a day I need show the events scheduled this day from 13pm to 7am (next day) ... Do you think this could be achieved with the current date filtering?

Thank you for your help

j.

#570278

Amir
Supporter

This question is coming from our announcement blog post, here:
https://toolset.com/2017/09/preview-for-many-to-many-relationships-in-toolset/#comment-323759

I'm also subscribing to see if we can do this today. If not, Toolset dev will step in and see what we can do to help in the near future.

#570285

Just a thing, we need the support but by now this is not urgent, next festival starts is in august 2018, we have all the winter to solve this...

Last two years we solved this question adding a custom field with the date number (12, 13, 14,...) and calling the events in the schedule using this field instead of date/time field to call events for a particular day. But we also had to use date/field number to store the event "real" date/time (as we also need to show this data).

For us it would be much better if we could only use one field (date/time) to store this data and then be able to call/show the events with a view that allow us to show the time slot that we need to show (from 1pm to 7am) for a particular day.

Do you think this could be done with views filter?

#570385

Dear Manuelan,

I assume we are talking about this case:
- festival A
--- Day 1 (September 16, 2017 13PM ~ September 17, 2017 7AM)
--- Day 2 (September 17, 2017 13PM ~ September 18, 2017 7AM)
- festival B
--- Day 1 (September 11, 2017 13PM ~ September 12, 2017 7AM)
--- Day 2 (September 12, 2017 13PM ~ September 13, 2017 7AM)
...

You need a custom search form with a date-picker, if the user choose date value "September 11, 2017", you are going to display the "festival B" + "Day 2"

1) So in current version of Toolset plugins, it needs a child post type + two date fields
For example:
Parent post type "festival"
- Child post type "festival days", with two custom date field "start time" and "end time",
See our document:
https://toolset.com/documentation/user-guides/creating-groups-of-repeating-fields-using-fields-tables/

Then you will be setup a view to query the child "festival days" posts, and setup custom search form with date-picker field, use it to pass URL parameters, for example "my-date", and filter the view with:
Select items with field:
"start time" is a number lower than or equal URL_PARAM(my-date)
AND
"end time" is a number greater than or equal URL_PARAM(my-date)

Then you will be able to get the related child "festival days" posts, and display it's parent "festival" post information:
https://toolset.com/documentation/customizing-sites-using-php/displaying-parent-posts/

2) For the problem:
when a user select a day, I need show the events scheduled this day from 13pm to 7am (next day)

When user submit the search form, you can use filter hook "wpv_filter_query" to trigger a PHP functions, in this function, do these:
a) get the value of URL parameter "my-date",
b) add 13 hours in above value, and get new value, apply the new value into query.
More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
wpv_filter_query
When displaying a View listing posts, this filter is applied to the arguments being generated by the View settings before they are passed to the WP_Query class.

#570945

Thank you Lou Yang,

Our case is not exactly as you described, we have an 8 days festival, with 20 areas with musical (live shows, djs,...) and cultural events (talks, workshops,...).

To manage this we have a set up a cpt called EVENTS, another one called GUESTS and last a cpt called AREAS, actually events and guests are related by a many-to-many relation with a cpt connector (appearances) between them, at this moment areas is simply parent of EVENTS. With the new many-to-many I think we will can set up the relations as we want (areas and guests are parent of events)

Our objetive is that when we see:

- a guest: we can see all his activities in the festival,
- an event: we can see all the guests participating on it (and event data: day, time, area,...)
- an area: we can see all the scheduled events and also a list of the scheduled guests in the area.

ROTOTOM FESTIVAL

- AREA A
--- EVENT 1 (August 12, 2017 13PM ~ August 12, 2017 14PM)
--- EVENT 2 (August 12, 2017 14PM ~ August 12, 2017 15PM)
--- ...
--- EVENT 3 (August 13, 2017 05AM ~ August 13, 2017 06 AM)
--- ...
--- EVENT 7 (August 15, 2017 13PM ~ August 15, 2017 14PM)
--- EVENT 8 (August 15, 2017 14PM ~ August 15, 2017 15PM)
--- ...
--- EVENT 9 (August 16, 2017 05AM ~ August 16, 2017 06 AM)

- AREA B
--- ...

So when we select AUG 12 (i.e) we need to show all EVENTS scheduled between August 12, 2017 13PM ~ and August 13, 2017 07AM.

Now our developer is on holidays, I will check your answer with him and If we still need help I will come again to the support forum with our questions.

Thank you very much.

#571236

Yes, you are right, you can setup the many-to-many relationship between post type "Event" and "Guest", and please update this thread if you need more assistance for it.

#572528

Ok, We will try. Thank you for your help

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