encho Posted November 21, 2017 Share Posted November 21, 2017 Just recently I have discovered that in your selectors you can do something like: $events = $pages->find("template=weekly-event, date<='next Friday'"); which is great! To take it step further, if my date field is not unix timestamp, but needs to be converted to such, what to do? For example I have field 'day_in_week' (can be Monday, Tuesday, etc.) and want to find all the events by that arbitrary last day. In short, something like: $events = $pages->find("template=weekly-event, today<='next {day_in_week}'"); Obvious problem is 'today' can not be selector and 'day_in_week' is dynamic. Hope I haven't over-complicated the things. Any input more than welcome! Link to comment Share on other sites More sharing options...
Tom. Posted November 21, 2017 Share Posted November 21, 2017 Maybe I miss-understanding, but you have a day_in_week field, what kind of field is this? Before I can answer the question, as this changes the way you can achieve this. For example if it's just text you can do: $events = $pages->find("template=weekly-event, day_in_week=Monday"); 2 Link to comment Share on other sites More sharing options...
Robin S Posted November 21, 2017 Share Posted November 21, 2017 7 hours ago, encho said: Obvious problem is 'today' can not be selector and 'day_in_week' is dynamic. Do you mean you want to get the current day of the week and use it in the selector? Maybe this is what you want: $day = date('l'); $events = $pages->find("template=weekly-event, day_in_week=$day'"); 1 Link to comment Share on other sites More sharing options...
encho Posted November 24, 2017 Author Share Posted November 24, 2017 On 11/21/2017 at 5:37 PM, Tom. said: Maybe I miss-understanding, but you have a day_in_week field, what kind of field is this? Before I can answer the question, as this changes the way you can achieve this. For example if it's just text you can do: $events = $pages->find("template=weekly-event, day_in_week=Monday"); On 11/21/2017 at 11:52 PM, Robin S said: Do you mean you want to get the current day of the week and use it in the selector? Maybe this is what you want: $day = date('l'); $events = $pages->find("template=weekly-event, day_in_week=$day'"); Sorry I wasn't clear enough. I want to make recurring events, that can merge with the rest of the events. I know how to combine 2 selectors, first one would be something like $events = $pages->find("template=event, sort=-date"). Second selector is an issue, where I want it to get the events from weekly_event template and merge them into the non-recurring events. Weekly event template has 2 fields: day_in_week (selector of Monday, Tuesday, ...) and duration (integer representing hours). My selector would generate the date that is this week, day_in_week. So for example, if today is Monday, 1st January and one of the recurring events is Thursday, it will generate date for that recurring event to be 4th January. That way, if that recurring event has real date associated with it, it can be merged and sorted together with the rest, non-recurring, events. Anyway, seems that one of the plugins is doing what I'm looking for and more and I'm probably going to buy it and save myself a lot of headache. Thanks for your efforts. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now