Add Link Class to Title field

Created on 4 February 2021, over 4 years ago
Updated 23 December 2023, over 1 year ago

Problem/Motivation

When using the "Title" field provided by display suite, in the 3rd party settings we are able to check a "Link" checkbox to output the title wrapped within an A tag. This works great, but there is no further way to control the output of the link, since it comes from an embedded twig template within /src/Plugin/DsField/Field.php.

In almost every site we build, I want to add classes to these links, for example using Boostrap, the "stretched-link" class can be added so I can make my entire card clickable.

In the past I've achieved the same thing by using the patch to provide token support in the prefix/suffix and expert display mode with the token for the entity alias. Or I add the "Read More" display suite field into my designs, and add the link classes i want there. These are both workarounds. In the end, they don't cover all cases, and an produce extra markup.

In a recent patch, blank attributes were added to links for preprocessing. This patch connects the dots with that patch and the Field UI.

Steps to reproduce

  1. Add a title field on a DS enabled view mode.
  2. Check off link
  3. Try to figure out how to theme that link with a class

Proposed resolution

Add in link attribute support to the title field, when link is checked off.

Remaining tasks

TBD

User interface changes

  • Adjust the 3rd party settings to add a link class field for title
  • Update the summary to show it.

API changes

None

Data model changes

  • Add the link class to the default config of the title field.
✨ Feature request
Status

Fixed

Version

3.0

Component

Field UI

Created by

πŸ‡ΊπŸ‡ΈUnited States devkinetic

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024