I am trying to set office hours for a place that is closed for the summer. When I leave all the time fields blank nothing shows up when I publish the page. I have the "Show all days" selected under Managed Display. I would like to have the hours show "closed" instead of not publishing the hours at all.

What do I need to do to make this happen?

I have tried altering the "office_hours_field_is_empty" function in the .module file but it didn't seem to make any difference. Any help would be appreciated.

CommentFileSizeAuthor
#4 business_hours.png9.8 KBjohnv
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

I guess this is a valid feature request, given you have selected to show all days, even if they are closed.
However, for most entities, leaving all fields empty, just means that the entity has unknown, or no opening hours.
We'd need an extra option, I suppose, to distinguish etween the two.

For starters, you should change function office_hours_field_formatter_view(), and remove the first lines:

  if (!$items) {
    return $element;
  }

If you have something ready, please post your results!

mnshantz’s picture

That's great, thanks John!

Yes, I figured I would need to override the existing behaviour because in normal use cases that is what you would want.

johnv’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)
Related issues: +#2044465: Add links 'clear' and 'apply to all' to Widget to improve usability

For a definitive solution, we need a solution like here: #2044465: Add links 'clear' and 'apply to all' to Widget to improve usability

johnv’s picture

Title: Is there a way to display all days as closed? » Add checkbox to display all days as closed
Category: Support request » Feature request
Status: Closed (duplicate) » Active
FileSize
9.8 KB

Let's refocus this issue to adding a checkbox. See attached image.
Still need to figure out the exact usage. (what if: hours are filled and checkbox is set? Hours are empty and checkbox not set?)

smd_ksu’s picture

Agreed with checkbox application. Would allow you set a day to be closed without having to re-enter the time. Thinking of a school on spring break, they would set all the days as closed then reopen without having to setup each day over again.

johnv’s picture

Title: Add checkbox to display all days as closed » Add option to display 'Closed all week'

Moved as duplicate #2487460: Closed all week

Posted by smd_ksu on May 12, 2015 at 5:46pm
If a business is closed all week the hours display is blank even with Show all days selected in the field display. The blank default behavior is understandable so there should probably be an option to select desired behavior.

johnv’s picture

See both linked issues for D7 and D8. It adds a 'comment' column to each time slot.
We can build upon that.

johnv’s picture

Component: Code » Code - widget
johnv’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Component: Code - widget » Code - formatter

let's move this to the D8-version.

In the D8-version, we now have a hidden feature '#empty' => t('This location has no opening hours.'), in the formatters. We can add this to the settings page, and use it if necessary.

johnv’s picture

johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.1
Status: Active » Fixed
Related issues: +#2860041: Cannot add comment when day is closed.

Issue #2860041: Cannot add comment when day is closed. is fixed.
You can now add a comment without a time.
Using the formatter setting "Group consecutive days with same hours into one set" , you can create 1 line for all week.

I guess the above change covers most of your needs.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.