Provide a hook/event for modifying the suggestions list

Created on 14 June 2023, over 1 year ago
Updated 31 August 2024, 3 months ago

Problem/Motivation

I would like to set additional attributes on the link element being created. Currently, the module returns data-entity-{type|substitition|uuid], but for our decoupled architecture and styling we want/need to also include bundle|id|internal-href.

With CK4 this was possible through hook_form_alter. With CK5, and the form being rendered by the UI, it is cumbersome to manipulate the element attributes. Any logic beyond simple entity attribute selection would require an entire custom MatcherPlugin + manipulation of the existing plugin definition and/or significant configuration changes to use the custom plugin.

Being able to modify the suggestion list would easily allow additional, complex data to be returned and also allow more contextual filtering (eg: only suggest links to content of the same type). A custom CK5 plugin would still be needed but would be far simpler with the data already present in the suggestion results.

Proposed resolution

Implement `\Drupal::moduleHandler()->alter` and/or dispatch and Event to allow other modules to modify the suggestion list.

✨ Feature request
Status

Active

Version

7.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States wweibel

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

Comments & Activities

  • Issue created by @wweibel
  • πŸ‡ΊπŸ‡ΈUnited States wweibel
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Interesting suggestion.

    To state back what I'm hearing, the rationale for this is twofold:
    1. To easily allow additional, complex data to be returned
    2. To allow more contextual filtering (e.g.,: only suggest links to content of the same type)

    I support, in principle, the addition of an API hook to allow modifying the data attributes in the suggestions list.

  • We have a use case for this with the domain access module. Adding a check to not show content tied to other domains so it'd be under: allowing additional contextual filtering.

Production build 0.71.5 2024