Appearance
Opening hours fieldtype
The Maps Locator Opening Hours fieldtype keeps the opening hours of a location: a week schedule and exceptions on a date, e.g. a holiday. In your templates it shows the hours, whether the location is open now and when it opens or closes, and the hours as schema.org data for search engines. (from v4.0.0)
Add a field of the type Maps Locator Opening Hours to the channel of your locations, next to the Maps Locator (or Maps Fieldtype) field. The examples below use a field store_hours.
The field
- Week: the opening and closing time per day. A day without times is closed. A second block is for e.g. a lunch break (09:00 - 12:00 and 13:00 - 17:30). A block that closes before it opens runs past midnight (22:00 - 02:00).
- Exceptions: other hours on a date, with a description (e.g. Christmas). Check Closed for a day without opening hours. An exception replaces the week schedule on that date. Add an exception adds a row.
The times use the timezone of the site (Settings > Date & Time).
The field works in a channel, not in a Grid or Fluid field.
Template tags
Single tag
The week as a table, today has the class opening-hours__today:
{store_hours}Tag pair
{store_hours}
{if open_now}
Open now, until {closes_at}
{if:else}
Closed{if opens_at}, opens {opens_day} at {opens_at}{/if}
{/if}
<table>
{days}
<tr{if is_today} class="today"{/if}>
<th>{day_name}</th>
<td>{if closed}Closed{if:else}{hours_text}{/if}</td>
</tr>
{/days}
</table>
{if has_exceptions}
<h3>Holidays</h3>
<ul>
{exceptions}
<li>{date format="%d-%m-%Y"} {label}: {if closed}closed{if:else}{hours_text}{/if}</li>
{/exceptions}
</ul>
{/if}
{/store_hours}| Variable | |
|---|---|
{open_now} | Open at this moment |
{closes_at} | When it is open: the closing time |
{opens_at}, {opens_day} | When it is closed: the next opening time and its day (today, tomorrow or the name of the day), within a week |
{hours_today} | The hours of today, e.g. 09:00 - 12:00, 13:00 - 17:30, empty when closed today |
{closed_today} | Closed all day today |
{today_label} | The description of the exception of today, e.g. Christmas |
{days}...{/days} | The week, from Monday: {day} (1 is Monday), {day_name}, {is_today}, {closed}, {hours_text} and the pair {hours}{opens} - {closes}{/hours} |
{exceptions}...{/exceptions} | The exceptions from today on: {date format=""}, {date_ymd}, {label}, {closed}, {hours_text} and {hours}{opens}{closes}{/hours} |
{has_exceptions} | There are exceptions from today on |
Modifiers
{store_hours:open_now} 1 when open now, else empty
{store_hours:closes_at} the closing time when open
{store_hours:opens_at} the next opening time when closed
{store_hours:opens_day} today, tomorrow or the day of the next opening time
{store_hours:hours_today} the hours of today
{store_hours:schema} the hours as schema.org openingHoursSpecification (JSON)time_format
The format of the times, a PHP date format. Default H:i (09:00), e.g. g:i a for 9:00 am. On the single tag, the tag pair and the modifiers.
{store_hours time_format="g:i a"}schema.org
{store_hours:schema} gives the hours as an openingHoursSpecification list: the days with the same hours together, and the exceptions from today on with their date (a closed day opens and closes at 00:00, as schema.org describes it). Use it in the JSON-LD of a store:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Store",
"name": "{title}",
"openingHoursSpecification": {store_hours:schema}
}
</script>