Add option for link target

Created on 5 June 2019, almost 6 years ago
Updated 21 November 2024, 5 months ago

I use link_class instead of link_attributes because it's easier for content editors. With the class select list they don't need to know which class names to add, they just select the name of the desired style. A common request is to allow them to choose to open a link in a new window. It would be nice to have this option.

Feature request
Status

Needs review

Version

1.3

Component

Code

Created by

🇺🇸United States jascote

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

Comments & Activities

Not all content is available!

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

  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺

    Just added the None option. Very useful feature.

  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺

    Didn't do the tests.

  • 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺

    Actually breaks W3C compliance. When not filled, it is adding an empty target attribute which is not valid.

    target=""

  • 🇮🇳India shivam_tiwari

    I am working on this issue.

  • 🇮🇳India shivam_tiwari

    @flocondetoile I worked here and checked target attribute on the link. If we use none option for target then an empty target attribute comes with link tag. Can we create a separate Field Formatter for this?
    cc @maintainers

  • 🇫🇷France flocondetoile Lyon

    A field formatter is not in the scope of this module. It's not the right way to support this.

  • 🇮🇳India shivam_tiwari

    @flocondetoile I worked on it. Added a checkbox for the setting of this link-target field by the field widget file. This means if user makes setting for display target field with the link class field then only it will show on the link field-related forms.
    But if user sets to none option then on the link field empty target attribute comes. Actually, it is related to form API. If we take any field, after submitting the form, form api is taking all the form fields.
    Can we not remove the none option from target field? Because none option and Open in the same window (_self) attribute work same and link will open in the current window only. We can also apply JS for checking and removing the empty target attribute by module but I think it will not be a good method. Because this will check all the links on the page. Same thing will apply for preprocess also, it will apply on all the links.
    Can you please guide me here, what can we do?

Production build 0.71.5 2024