Skip to content

Repository files navigation

UNCCD Event Map Drupal Module

The UNCCD Event Map Drupal Module display a map of events. Users can add events, which after approval appear on the map. Live version: UNCCD Events Around the World 2018

User Guide

Installing the module

The module requires Drupal 8.x, and has no other module dependencies. To install the module:

  1. Create a new folder "unccd_eventmap" inside "docroot/modules/unccd"
  2. Place all of the files from this repository inside the above folder.
  3. Go to "Extend" in the Drupal admin panel.
  4. Find UNCCD Event Map in the module list, and check the box next to it
  5. Click "Install" at the bottom of the page
  6. Clear the cache by running "drush cr" or go to "Configuration -> Performance" and click "Clear all caches"

Updating the module

To update the module:

  1. Update the contents of "docroot/modules/unccd/unccd_eventmap" with the contents of this repository
  2. Clear the cache by running "drush cr" or go to "Configuration -> Performance" and click "Clear all caches"

Usage

The module introduces two new blocks:

  • Event Map Block: Displays approved events on a map
  • Events Around the World Block: Displays approved events by country/continent These blocks can be inserted into any page in Drupal settings (Structure -> Block layout). The blocks by default show all the events, but can be restricted to a specific year in the configuration of each block.

The public form for adding events is acessible under /event-map/form, and also from a link included in the Event Map block.

The module also adds an admin panel page to manage events, which can be accessed at Structure -> UNCCD Event Map Events.

The permission "Manage UNCCD Event Map" can be given to users for them to be able to approve, edit and delete events.

Development

Folder structure

  • /config/install/unccd_event_map_config.yml The default values for the module configuration
  • /src/Controller/
    • EventAdminController.php The controller for the admin panel pages
    • MapController.php The controller for the admin panel pages
  • /src/Form/
    • AddEventForm.php The form to add new events in the admin panel
    • ConfigForm.php The form to change map configuration
    • EditEventForm.php The form to edit events
    • PublicEventForm.php The public form to submit events
  • /src/Plugin/Block/
    • EventMapBlock.php The event map as a Drupal Block
    • EventsAroundTheWorld.php The list of events split by continent and country
  • /src/Utils/
    • ContinentSpliter.php A utility which can categorize countries by continent
    • Geocoder.php A utility to convert addresses into latitude/longitude
  • /src/EventStorage.php A class managing the database storage of events
  • /templates The view of the pages/blocks
  • README.md This file
  • unccd_event_map.info.yml Description of the module
  • unccd_event_map.install A script ran when the module is installed. Adds the database table.
  • unccd_event_map.libraries.yml The list of js and css files used by the module.
  • unccd_event_map.link.action.yml A list of actions to add to the admin panel
  • unccd_event_map.links.menu.yml A list of menu entries to add to the admin panel
  • unccd_event_map.module Defines the view templates used by the module
  • unccd_event_map.permissions.yml A list of new permissions added by the module
  • unccd_event_map.routing.yml A list of new routes added by the module (both public and admin panel)

Database Schema

The module adds one additional database table called "unccd_event_map", it has the following fields:

Column nameTypeDescription
idintPrimary Key: Unique event ID.
titlevarcharTitle of the event.
organisationvarcharOrganisation running the event.
organisation_urlvarcharUrl of the event organizer(s)
urlvarcharURL of the event on an external website.
emailvarcharEmail of the contact person.
cityvarcharCity where the event takes place.
countryvarcharCountry where the event takes place.
datedatetimeThe date the event takes place on.
descriptiontextDescription of the event
latitudefloatThe latitude of the location of the event (for map display)
longitudefloatThe longitude of the location of the event (for map display)
approvedtinyintHas the event been approved?
image_idintThe Drupal file id for the uploaded image (needed to delete image when event is deleted)
imagevarcharUrl of the event image
attachment_typevarcharThe type of PDF attached (report, flyer, etc...)
pdf_idintThe Drupal file id for the uploaded PDF (needed to delete PDF when event is deleted)
pdfvarcharUrl of the event PDF

Geocoding

The module has two different geocoding services implemented to convert from the user entered city and country to a latitude/longitude on the map.

The module implements Geocoding with OpenStreetMap Nominatim, GoogleMaps API, MapQuest API

The OpenStreetMap implementation is enabled by default.

External libraries

The module uses three third-party JavaScript libraries:

  • Leaflet: The interactive mapping library used to display the OpenStreetMaps tiles (Version: 1.3.1)
  • Leaflet MarkerCluster: Clusters nearby pins to reduce clutter and make the map cleaner (Version: 1.3.0)
  • Leaflet FullScreen: A button to fullscreen the map (Version: 1.0.1)
  • Date Picker: A date picker for the user event submission form (Version: 0.6.5)

About

A Drupal module which allows the display of a map of events. Users can add events, which after approval appear on the map.

Topics

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages