Contextual links are missing when using the Card SDC (and maybe others too)

Created on 7 August 2024, 6 months ago
Updated 10 September 2024, 4 months ago

Problem/Motivation

I was wondering how to add contextual links to entity templates using the for example the Card SDC.
Maybe I missed something, but the only way is to wrap the card in a contextual region wrapper and print the contextual links inside that wrapper. Which is not really a good thing in terms of the resulting markup.

Steps to reproduce

Override the template of, for example taxonomy-term--card.html.twig, add the card SDC:

{%
  include 'radix:card' with {
    card_title: name,
    card_title_tag: 'h3',
    card_title_utility_classes: ['h3'],
    card_utility_classes: ['text-center', 'fs-md'],
    card_border: true,
    card_body: content|without('field_coverimage'),
    card_link_url: url,
    card_link_text: 'Details'|t,
    card_link_utility_classes: ['mt-2', 'btn-outline-dark'],
    card_media: content.field_coverimage,
  }
%}

Proposed resolution

Add a card_contextual_links property, if not empty, add the "contextual-region" class to the card wrapper and print the contextual links inside.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Fixed

Version

6.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024