code snippets

Mass and Sacrament Times on the Archdiocese of St. Louis' Website

One question I'm often asked by many other diocesan web development teams/individuals is how we put together our online Mass Time search (also used for searching adoration and reconciliation times). We also get questions about how we do our online mapping—but I've already covered that (see: Beautiful, Easy Maps in Drupal using Views and Mapstraction).

Mass Times Search Interface
The Archdiocesan Mass Times search interface (click to enlarge)

We already have a database provided by the Archdiocesan IT department (they maintain it with the help of our diocesan Parish Support staff, and parish secretaries who can update their own schedules and information), so we needed to do the following on the web:

  • Import all the Sacrament time information and attach it to a parish node (so times/days could be affiliated with parishes).
  • Display the time information on parish node pages, in a meaningful way.
  • Allow users to search by Sacrament times, showing parishes on a map, and showing the Sacrament times in a list under the map.

I'll cover each of these important aspects of our website's functionality below.

Preliminary note: much of this code was provided originally by the great folks at Palantir, who helped us set up this and many other features on the Archdiocesan website...

Importing time information, attaching it to Parish nodes

The first step in the process is importing some 3,000+ parish event nodes (which contain data for each 'event' - the event time, the event type (Mass/Reconciliation/Adoration), whether the event is a 'Normal Service' or a special kind of Mass, the location of the event (often in a side chapel or somewhere else), the event day, and the reference for the parish to which the event is attached.

Our site uses the Migrate module to import all the data, and we have the module set up to import all the events first, then import the Parishes, attaching the events to parishes (through custom code) using a node reference. Continue Reading »

Set a View's Context Inside an Organic Group

A very simple way to allow a view to display as if it were a page in an organic group on your Drupal site: Simply paste the code below in your view's Header or Footer, using the PHP Code input format.

<?php
og_set_group_context
(node_load(46405));
?>

Note: the node ID inside node_load() must be set to the group into which you'd like the view to display. To get this to function perfectly (as of OG 2.1), you might need to apply the patch in this issue on drupal.org: Group theme doesn't display on Views that take group as an argument. (Otherwise the group's custom theme might not get set).

There are some alternative methods to getting views to display inside groups, but this is a quick and easy solution.

Syndicate content