2

On our company contact page we have a footer with contact information that should change based on whether or not we're open. I'm using Low Variables to store this information and have standard office hours in there with a Time Select. That part is easy enough. It's the office holidays that are stumping me.

1. Easy Solution:

I build in a Matrix field where we enter, say, the next five years of holidays. Then I match the current date against that list when loading the contact page and show the appropriate footer.

2. More Automated/Awesomer Solution:

? I'm not sure. This is tricky because of things like Thanksgiving, or holidays that span multiple days. Ideally I'd just use some public holiday calendar feed and check off the holidays we honor.

Suggestions? Unfortunately I don't have time to develop something custom. May need to go with option #1 for now.

3

I hear what you're saying about automating but in reality just how many holidays do you honour? It's not going to take too long to do it manually.

I would create a channel for holidays and create an entry for each holiday with the entry and expiration dates set.

Then on your template use a channel entries tag pair with show_future_entries="no"

In theory this will mean that your holiday entries will be shown on the days you are closed.

I would think that it would be more useful to show entries a little bit in the future to give people notice of upcoming closures. In this case there are 2 simple options;

You could set the entry dates a little in advance (with a different field to display the actual closure dates)

or

Use a custom SQL query to grab entries with dates in the near future. MySQL has some really useful date handling functions so this shouldn't be too troublesome.

| improve this answer | |
2

Try making this a global variable in your config file, then you can do all the date checking in PHP. Go to http://www.epochconverter.com/ and get the start and end date of when you're closed, then add this to your config.php file.

if (time() > 1387497600 && time() < 1388016000) {
    // Use this in your template {hours_open} and it'll show if the 
    // date is between Dec 20th and Dec 27th
    $assign_to_config['hours_open'] = 'Whatever you want here.';
} else {
    // Otherwise don't show anything
    $assign_to_config['hours_open'] = '';
}

Note that $assign_to_config creates early parsed global variables, so you could instead set the values to TRUE or FALSE, then in your template do this:

{if hours_open}
    Yes, we're open on this day!
{if:else}
    Sorry, closed
{/if}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.