Note: This Feature is now ready.
Your feedback is highly appreciated. For example, Do you want the regular weekdays to disappear, when a season hits in, or when any season is maintained?
Problem/Motivation
We need seasonal office hours for our databases of restaurants and tourist destinations.
It would contain the following fields:
| fields | description | period | office_hours |
|---|---|---|---|
| Regular hours | Regular | empty (?) for always | mo-fr 09:00-17:00 |
| Season | Summer 2012 | 1-jul-2012/31-aug-2012 | mo-fr 14:00-17:00 |
| Exception 1 | Eastern 2012 | 1-apr-2012 | closed |
| Exception 2 | Christmas | 25-dec-20nn | closed |
Proposed resolutions and alternatives
- 1. create a submodule of office_hours providing a field_collection comprised of several fields.
- 2. create formatter for the provided field_collection that shows the office_hours corresponding to the matching season for today.
- 3. See also the (install file of the) Measured Value Field module. This is a composite field using the composing field types.
- 4. Version 8.x-1.8 of this modue will contain Seasons and Exceptions.
- Alternatives
- this can already be implemented using the Field collection module;
- add an 'office_fields_addendum' textfield to the entity, describing the exceptions. Show the field together with the office_hours field;
- #2862302: [Season] Add Recurrence Rule for Views (Full)Calendar integration (ISO-8601 or RRULE)
Examples:
Remaining tasks
- Decide which implementation to use.
- Implement exceptions (Dates or periods that are excluded from the opening times, like holidays, X-mas).
Suppose two field_collections 'Regular' and 'Summer 2012'. You don't want to change Regular each time. During 'Summer 2012', how to suppress the 'Regular' times?
- Implement seasons;
- #2862302: [Season] Add Recurrence Rule for Views (Full)Calendar integration (ISO-8601 or RRULE)
- #3335549: Refactor 'Weekwidget with exceptions' as Widget of Widgets
User interface changes
n/a
Related Issues
n/a
Original report by ASMBL
I was wondering about options in the Field Settings that would allow for seasonal hours. This could be broadened to applicable period so as to not limit it, and account for a great variety of options. Something along the lines of:
- Are these hours applicable to a range of dates or period? y/n
- Single or multiple periods? (creates desired number of tables)
- Enter the applicable dates, and title of period(s) (ie Winter hours, Summer school, Spring Production, Fall Winter Programs):
These conditions could also be entered from the Add Content form to give client control. Something like:
- Expose these options during content creation? y/n
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | Screenshot_20220726-053448.png | 122.93 KB | zenimagine |
| #11 | office-hours-output.png | 41.49 KB | alan d. |
| #11 | office-hours-input.png | 30.95 KB | alan d. |
| #8 | office-hours-separately.png | 8.36 KB | antonín slejška |
| #8 | office-hours-in-field-collection.png | 32.02 KB | antonín slejška |



Comments
Comment #1
jonhattanI think of a submodule of office_hours providing a field_collection comprised of a date field and an office_hours field.
A formatter for the provided field_collection would show the office_hours corresponding to the matching season for today.
Comment #2
antonín slejška commentedWe need seasonal office hours for our databases of restaurants and tourist destinations (www.ceskesvycarsko.cz). It could look like:

Comment #3
gunwald commentedI agree to that, but maybe we could find a more general solution: We could use a date field (on the same node) to add dates or periods that are excluded from the opening times. I am thinking about holidays and so on. What do you think?
Comment #4
antonín slejška commentedI'm not sure if it would be enough user friendly even for non-technically educated editors :-)

Here is some example what we need to solve (and it can be even more complicated):
http://turistika.ceskesvycarsko.cz/en/locations/decin-chateau
Comment #5
johnv@Antonín Slejška , a work-around might be to create a field_collection with Date field and office_hours field (like jonhattan proposes, but without separate submodule).
Comment #6
antonín slejška commentedThank you John! It is absolutely simple and straightforward solution. I'm going to implement it.
Comment #7
antonín slejška commentedThank you John! It is absolutely simple and straightforward solution. I'm going to implement it.
Comment #8
antonín slejška commentedI created a field_collection including an office_hours field. If I use the office_hours field separately, then it works exactly according to the configuration. See the picture:


But when I use it in the field collection, then the "Add more hours" link is not displayed and the selected granularity of time is ignored. See the picture:
If I use the separate field in the same form as the field collection, then both fields are displayed correctly. It was tested on two Drupal 7 sites with the same results.
Comment #9
johnv@Antonín Slejška, please search/open another issue for problems with field_collection. So we can use this issue for the original request.
If you use the dev-version, field_collection must work. See #1689296-12: Add more hours link won't work with Field collection module
I tested just now, and there is some widget problem, but works correctly.
Comment #10
johnvUpdated issue summary.
More clarifying title.
Comment #10.0
johnvUpdated Issue summary.
Comment #10.1
johnvAdd table layout
Comment #10.2
johnvupdate table layout
Comment #10.3
johnvdescribed new alternative with textfield.
Comment #11
alan d. commentedThe above approach didn't work for me, and I manually handled this. But it would be great to be passing in some more context to the theme_office_hours_field_formatter_default() so hackers like myself can implement our own solutions:
includes/office_hours.formatter.inc
Or if you are feeling generous, in office_hours_field_formatter_view():
It still was fairly painful to implement what I wanted, I used a simple textarea to store the public holidays (no Field Collection on this site) and way too much custom coding / time wasted...
I couldn't seem to hook into the field prior to the processing, so I created a custom formatter to decorate this modules formatter, i.e. only custom code was via hook_field_formatter_view();
Then overrode the theming function with the above hack to provide the context to control the final output.
FYI, a couple of screenshots are attached of the final result before theming.
The last bits are node nid's to link to a view page if they are being displayed there. (i.e. date(s)|label|nid)
Comment #12
marcoka commentedhttps://www.drupal.org/project/opening_hours can actually do that :)
Comment #13
alan d. commentedlol, duh. The usage stats pushed me here :(
Oh well, it was an interesting side project for the weekend, and it is working nicely with a relatively simply UI to add upcoming dates easily, or I should say, quickly. One hack (#2508755: Provide more context to the theming function.) and one custom formatter which would be redundant with #2508753: Add drupal_alter() to allow users to update the items before viewing.
Comment #14
johnvFWIW, the drupal_alter() from #11 is now implemented in dev-version or the next 1.5 version.
Comment #15
johnvComment #16
johnvPushing to D8.
ITMT, both D7 and D8 versions have a 'comment' field on each time slot. That might suffice for some use cases.
Comment #17
zenimagine commentedWhy not add paragraph to the module? Would not it be easier ?
https://www.drupal.org/project/paragraphs
and
https://www.drupal.org/project/calendar
Comment #18
johnvPlease elaborate.
Comment #19
zenimagine commentedThe "Field collection" module has not received an update for a long time and it is written on the module page that it will be obsolete and replaced by "Paragraph".
http://drupal.org/project/field_collection
Comment #20
zenimagine commentedHello, is this functionality planned for the next version? Thank you
Comment #21
johnvHi I have no active plans for this feature. I need a good architecture, first. Perhaps the D9-version would be a good start, when we can change the data model using proper times, instead of 4-character strings to store the times.
Comment #22
johnvComment #23
johnvComment #24
johnvComment #25
zenimagine commentedIt would be to enter the responsive schedules on the Olivero theme, which is now the default theme of Drupal 9
Comment #26
johnvI think the best way forward is to implement #2862302: [Season] Add Recurrence Rule for Views (Full)Calendar integration (ISO-8601 or RRULE).
With that in place, we can add seasonal hours, as described in that ticket.
Comment #27
johnvComment #28
johnvComment #29
johnvComment #30
johnvComment #31
johnvTo all followers,
I have created some new issues, in order to capture your feedback:
#3336378: [Season] Add season widgets, which contains a proof of concept.
#3336385: [Season] Add Seasonal formatter, which is completely blank.
Your feedback is highly appreciated.
Comment #32
johnvComment #33
johnvAs per #3336378: [Season] Add season widgets, the extended widget is now extended with Seasons, which can be activated using a field setting.
It is not ready for production sites, yet. If you are able to contribute that is appreciated. There is no need to only mention the omissions.
Also, the formatter needs to be adjusted. For that, more code maintenance must be done in #3340671: [Season] Formatter: Make better use of Item and ItemList.
Comment #34
johnvComment #35
johnv