GithubHelp home page GithubHelp logo

freekmurze / statamic-opening-hours Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marbles/statamic-opening-hours

1.0 2.0 0.0 12 KB

A Statamic add-on to set up and display opening hours

License: MIT License

PHP 78.92% JavaScript 21.08%

statamic-opening-hours's Introduction

An add-on to set up and display opening hours

Software License

With this Opening Hours add-on you can define the opening hours of your business in a settings panel. The add-on provides numerous tags to display or check the opening hours. A set of opening hours is created by passing in a regular schedule, and a list of exceptions.

This add-on requires >= PHP7.0

Screenshot

Installation

Download or clone the repository, rename the folder to OpeningHours then copy the folder to your site's Addon directory, then refresh the add-ons to install the dependencies.

php please addons:refresh

Usage

The add-on provides numerous tags, the base tag is {{ opening_hours }} but always requires a parameter.

{{ opening_hours:forWeek }}

Returns days with their opening hours.

<ul>
    {{ opening_hours:forWeek }}
        <li><strong>Monday</strong></li>
        {{ monday }}
            <li>{{ from }} - {{ to }}</li>
        {{ /monday }}

        <li><strong>Tuesday</strong></li>
        {{ tuesday }}
            <li>{{ from }} - {{ to }}</li>
        {{ /tuesday }}

        <li><strong>Wednesday</strong></li>
        {{ wednesday }}
            <li>{{ from }} - {{ to }}</li>
        {{ /wednesday }}
        
        ... 
        

    {{ /opening_hours:forWeek }}
</ul>

{{ opening_hours:forDay day="" }}

Returns the opening hours for a specific day

<ul>
    <li><strong>Monday</strong></li>
    {{ opening_hours:forDay day="monday" }}
        <li>{{ from }} - {{ to }}</li>
    {{ /opening_hours:forDay }}
</ul>

{{ opening_hours:forDate date="" }}

Returns the opening hours for a specific date. It looks for exceptions on that day, otherwise it returns the regular opening hours.

<ul>
    {{ opening_hours:forDate date="2017-05-25" }}
        <li>{{ from }} - {{ to }}</li>
    {{ /opening_hours:forDate }}
</ul>

{{ opening_hours:exceptions }}

Returns a list of all the exceptions.

<ul>
    {{ opening_hours:exceptions }}
        <li><strong>{{ date }}</strong></li>
        <ul>
            {{ hours }}
                <li>{{ from }} - {{ to }}</li>
            {{ /hours }}
        </ul>
    {{ /opening_hours:exceptions }}
</ul>

{{ opening_hours:isOpenOn day="" }}

Checks if the business is open on a day in the regular schedule.

{{ opening_hours:isOpenOn day="monday" }}
    <p>Yes</p>
{{ /opening_hours:isOpenOn }}

{{ opening_hours:isClosedOn day="" }}

Checks if the business is closed on a day in the regular schedule.

{{ opening_hours:isClosedOn day="sunday" }}
    <p>Yes</p>
{{ /opening_hours:isClosedOn }}

{{ opening_hours:isOpenAt date="" }}

Checks if the business is open on a specific day, at a specific time.

{{ opening_hours:isOpenAt date="2017-05-25 09:30" }}
    <p>Yes</p>
{{ /opening_hours:isOpenAt }}

{{ opening_hours:isClosedAt date="" }}

Checks if the business is closed on a specific day, at a specific time.

{{ opening_hours:isClosedAt date="2017-05-25 22:30" }}
    <p>Yes</p>
{{ /opening_hours:isClosedAt }}

{{ opening_hours::isOpen }}

Checks if the business is open right now.

{{ opening_hours:isOpen }}
    <p>Open</p>
{{ /opening_hours:isOpen }}

{{ opening_hours:isClosed }}

Checks if the business is closed right now.

{{ opening_hours:isClosed }}
    <p>Closed</p>
{{ /opening_hours:isClosed }}

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Special thanks to Spatie for making their Opening Hours package

About Marbles

Marbles is a digital communication agency based in Antwerp, Belgium. Learn more about us on our website.

License

The MIT License (MIT). Please see License File for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.