Library Hours

Hours are hard, especially with five libraries and custom hours within many of them. To solve this problem we created a custom solution inside Drupal.

Overview

How We Did It

Managing in Drupal

We created a Library Hours content type (see attached) to manage the hours. You'll see the Library Hours content type utilizes three other content types, Library, Service and Semester. The Library content type provides info about the library (location, contact info, etc). The Service content type provides information about each service within each library. The Semester content type provides the start and end dates of each semester.

The checkboxes (exception, exam hours, etc) are just used to further distinguish which Library Hours node, when we filter the data, to deliver to the front end.

The Hours part of this content type bears explaining. So each Library Hours node consists of a consistent set of data based on time. For example one node would be:

Hill Library, General Service, Summer 15, M-F 8am to 6pm

To get the weekend hours, which are different then the weekday hours its:

Hill Library, General Service, Summer 15, Sat-Sun 7am to 10pm

In other words each node is build on a consistently repeatable set of time based on the hours its open during the day. You would select the Repeat option and set it to repeat on the appropriate days of the week and repeat weekly until whichever end date your choose (in our case its the end of the semester).

Exceptions is another fun task. The way we have it set up is that each exception (closed on Christmas, closing early due to weather, etc) is its own node. Here we would check the exception checkbox and fill out the rest of the fields as needed.

Front-End

The hours page itself it just a collection of blocks that pull from views or JSON data(which I will explain later). Most of the blocks use customized templates.

The real time hours area on the left of the page is fed using JSON.

The calendar area is controlled by a view that uses the calendar module. There is a custom template to pull in the color coded information.

The content areas(library and service info) use the url segments to pull specific data.

Back-End

The installed modules used are Date and Calendar.

We had to create a custom module to handle the data. It turns the hours data into JSON which we use to populate the hours pages as well as sharing hours data with many apps across all the libraries. The module compiles the hours entered into they system into a day-by-day list which make it easier for the front-end to consume. Here you can see a sample of the hours in JSON format. Notice the url vars which are used to filter the data.

The vars are:

library_short_name = the library

service_short_name = the service within a library

date = the start date

end_date = the end date (optional if you only want a single day of hours)

hours-content-type-ss.jpg

Results

Team