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
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mrshowerman created an issue. See original summary.

mrshowerman’s picture

Assigned: mrshowerman » Unassigned
Issue summary: View changes
Status: Active » Needs review

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.

hexabinaer’s picture

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).

mrshowerman’s picture

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.

tobiasb’s picture

Version: 2.2.x-dev » 2.3.x-dev
Assigned: Unassigned » tobiasb

  • tobiasb committed 2cb468e8 on 2.3.x
    Issue #3462443: Configurable directions and public transport links
    

tobiasb’s picture

Assigned: tobiasb » Unassigned
Status: Needs review » Fixed

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.

mrshowerman’s picture

Issue summary: View changes

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

tobiasb’s picture

hexabinaer’s picture

@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.".

Status: Fixed » Closed (fixed)

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