Reinos.nl internet media examples

Store page with opening hours

Maps Locator 4.0.1 Live

The page of one store shows the week with today marked, the holidays and other exceptions, and the hours as schema.org data for search engines:

Template
{exp:channel:entries channel="stores" limit="1" url_title="{segment_3}" require_entry="yes"}
    <h1>{title}</h1>

    {store_hours}
        <p class="store__status">
            {if open_now}
                Open now, until {closes_at}
            {if:else}
                Closed{if today_label} ({today_label}){/if}{if opens_at}, opens {opens_day} at {opens_at}{/if}
            {/if}
        </p>

        <table class="store__hours">
            {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}
            <h2>Holidays</h2>
            <ul>
                {exceptions}
                    <li>{date format="%j %F"} {label}: {if closed}closed{if:else}{hours_text}{/if}</li>
                {/exceptions}
            </ul>
        {/if}
    {/store_hours}

    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "Store",
        "name": "{title}",
        "url": "{url_title_path='stores/detail'}",
        "openingHoursSpecification": {store_hours:schema}
    }
    </script>
{/exp:channel:entries}

Build it in your own site

What this example needs in ExpressionEngine, step by step.

  1. Install Maps Locator and Maps.
  2. Create the field, with these short names:
    Short nameTypeNotes
    store_hoursMaps Locator Opening HoursThe week and the exceptions (holidays).
  3. Create the channel stores (Stores) and assign the field.
  4. Put the code in the template stores/detail: the code links to it.
  5. Add a few stores (the demo site has 34 bike stores in the Netherlands).
  6. Open /stores/detail/bike-hub-utrecht (with the URL title of one of your entries).

This example comes from the Maps Locator docs: the preview runs exactly the code above.