Configurable directions and public transport links

Created on 18 July 2024, 5 months ago
Updated 11 September 2024, 3 months ago

Problem/Motivation

Directions links on locations and date pages currently work only on Android, due to the fact that they are using URLs with the geo: protocol.
Sites built on top of OpenCulturas may decide to use a different approach, such as OpenStreetMap or Google Maps URLs.

Similarly, it would be nice to be able to show links to public transport providers in the site's region, also based on the address field of a location.

This issue is for providing a general framework to achieve these goals.

Proposed resolution

Create a custom module OpenCulturas Address Links which offers a configuration form for defining the site's selected directions and public transport provider URLs. These URLs may contain tokens for real-time replacement of address info (e.g., latitude/longitude or the plain address). Integrate directions and public transport links both for template and field formatter based layouts.

Remaining tasks

  • Write update script that activates the new module
  • Review styling of links in base theme
📌 Task
Status

Fixed

Version

2.3

Component

Code

Created by

🇩🇪Germany mrshowerman Munich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mrshowerman
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • 🇩🇪Germany mrshowerman Munich

    OK, I think this is ready for review.

    The new module has a settings form at /admin/config/services/openculturas_address_links where you can specify URLs of your chosen directions and public transport provider. You can use tokens to include location coordinates or its plaintext address.
    By default, the public transport URL is empty, and the directions URL is set to geo:[geofield:latlon] to make it BC with the current behaviour.

    Example settings from KultinO:

    • https://www.google.de/maps/dir/?api=1&destination=[geofield:latlon] (directions)
      For OpenStreetMap, this could also be
      https://routing.openstreetmap.de/?z=18&loc=[geofield:latlon]&hl=[language:langcode]&srv=0.
    • https://www.vbn.de/fahrplaner/?start=yes&language=[language:langcode]&L=vs_vbn&Z=[address:address] (public transport)

    I've updated the openculturas_base_preprocess_paragraph() hook in the base template, so it now calls the new service for including links. This wil only work if the new module is activated, thus we will need an update script that enables it.

    For sites that prefer using field formatters together with field copies (like KultinO), the module also contains two new formatters.

  • 🇩🇪Germany hexabinaer Berlin, Germany

    Awesome, I'll look into it.

    On first reading of your description I wondered if this could work as a generic module (without OC dependency).

  • 🇩🇪Germany mrshowerman Munich

    I've asked myself the same thing. Theoretically, it could also be seen as an independent module, but as we only use it in an OC context (so far), I have treated it in the same way as the other modules for the time being.

  • Assigned to tobiasb
  • 🇩🇪Germany tobiasb Berlin
  • Issue was unassigned.
  • Status changed to Fixed 3 months ago
  • 🇩🇪Germany tobiasb Berlin

    Merged module. Some changes for CS/phpstan/rector happyness.

    The config values in openculturas_address_links.settings are now nullable. Because a empty string is not a valid uri.

    The modul will be installed via update-hook.

  • 🇩🇪Germany mrshowerman Munich

    Awesome.
    I'd really like to get credit for this one 😉

  • 🇩🇪Germany tobiasb Berlin
  • 🇩🇪Germany hexabinaer Berlin, Germany

    @mrshowerman On trying to construct a link with tokens there's a glitch:

    • Click in either of the 2 fields
    • Open token browser
    • Select a token, e. g. [geofield:latlon]

    Always results in a modal message "First click a text field to insert your tokens into.".

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024