You are here

Creating an automated events listing

By default the Healthwatch 'Website in a Box' provides a menu tab for 'Events'. Clicking the tab takes the user to a static page. This may be ok if details of small number of events are being published. Being essentially a static page it will also need to be updated regularly to avoid publishing old events.

The 'Website in a Box' package, however, provides all that is needed to turn this page into an automated event listing - showing a summary list of future events with a click through to an event detail page, similar to the News page. An example can be found here.

Date Field Module

The key to achieving this is the 'Date Field' module. Inactive by default, once turned on, this module allows date information to be posted with a start and end date. The module can be activated using Modules in the admin menu.

Creating a Content Type

The next step is to set up an Event content type. This will work like the News content type - so, once set up, a meeting would be posted as an Event. Content types can be created using Structure > Content types > Add content type. By default a content type has a title and body field. To keep things simple just one additonal field can be added - the date. With the 'Date Field' module activated a date/time widget is available for use with a new field.

Adding a View

With the content type added and a few initial events posted the next stage is to publish the listing. This is managed by a module called 'Views'. Views is already active and in use to display the News listing - so, this can be useful to take a look at as an example. Views admin options can be found in the Structure Menu (Structures > Views > Add new view). The admin screen essentially helps build a database query - so this may be fairly straightforward for users with database experience. Put simply the query will say "select all nodes of the content type 'Event' which are published and have a start date greater than now, order by date with the nearest event first".  The setting for 'Filter Criteria' and 'Sort Criteria' are the key to this. The date field will need to added to both - the filter criteria being set to pick events with a start date greater than now and the sort criteria to determine whether to show events by soonest first or last. The default field for sorting is the 'Post date' - this isn't relevant in this case and can be deleted.

Blocks and Pages

Views can be added to the site as blocks and pages. Views gives the option to create additional blocks. The full page listing can be created as a page or block, with an additional block for a few events coming up to go in a sidebar. Pager settings are set in the View itself whereas publishing and menu options for the view's blocks and pages are managed in Structure > Blocks and Structure > Menus

Calendars, Maps and Venues

This can be extended if necessary to provide a calendar view of events, maps and even Venue details:

Calendars: A calendar module is available and can be activated. It will then work with Views to provide a block with a calendar view. Views settings may be a little more advanced and a calendar may not always be the best approach. A simple listing may be better where the number of events is fairly modest - they may get lost in a calendar.

Maps: modules are also available to add maps to nodes so mapping can be acheived by extending the content type to hold location data. That said, it is also possible to get HTML snippets for embedding maps and this may be the quick and easy option.

Venues: the content type could also be extended to catch venue data in a structured way, for example adding fields for the venue name and address. A more advanced option still is to use Drupal's 'Entity Referencing' - a content type for venue can be added and this will allow a venue to be associated with an event through a radio button option or select menu on the event admin screen. If a lot of events are being posted and the same venues are being used repeatedly this could be a time-saver.

Fine-tuning CSS

The above options may require some fine-tuning of the theme's CSS to achieve the best results.