Problem/Motivation

There are a lot of use cases for having no title at all. For instance if you are replacing the text with an icon, it's better to have a completely empty link. In addition it will allow different node display modes to use different settings for displaying or hiding the link title.

Proposed resolution

Add a checkbox for the field display format to allow hiding the link title.

Remaining tasks

  1. Write Patch

User interface changes

Allowing 0 might be confusing for some users, so we should probably add some help text as well.
A checkbox labeled hide the link title seems very intuitive.

API changes

None.

Data model changes

None.

Comments

davidwbarratt created an issue. See original summary.

felribeiro’s picture

Assigned: Unassigned » felribeiro
swentel’s picture

Hmm, yeah, it's kind of confusing. If you empty the textfield, it works fine. So maybe we should just change the min to 0 and get that in for a patch release even ?

- edit - and even turn this into a bug report ?

davidwbarratt’s picture

The help text says:

Leave blank to allow unlimited link text lengths

Is that not happening?

felribeiro’s picture

Assigned: felribeiro » Unassigned
Status: Active » Needs review
StatusFileSize
new1.25 KB

Status: Needs review » Needs work

The last submitted patch, 5: 2641228-5.patch, failed testing.

prashant.c’s picture

StatusFileSize
new1.61 KB
new737 bytes

Made a minor change in the previous patch.

prashant.c’s picture

Status: Needs work » Needs review
swentel’s picture

+++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
@@ -146,8 +146,7 @@ public function settingsSummary() {
+    if (!empty($settings['trim_length']) || $settings['trim_length'] === 0) {

I guess we should add an explicit test for this too.

Status: Needs review » Needs work

The last submitted patch, 7: 2641228-7.patch, failed testing.

felribeiro’s picture

@prashant.c ,

I don't know if it's possible to use three "=" in $settings['trim_length'] === 0, because when I access the page, the field type is 'int' but when I click to configure and update, the ajax return is 'string' and shows a wrong message "Link text not trimmed".

felribeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new1.6 KB
mac_weber’s picture

What is the difference from the expected behavior of this patch and having the "Link text" set as optional?
If the Link text is not optional, then IMHO it must have some text.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

felribeiro’s picture

@Mac_Weber, It's different.
Suppose in the scenario that I have many display and one of them need to display the title and the other not, I need that the node save the title but the display will have option to show or not.

mac_weber’s picture

Status: Needs review » Needs work

@felribeiro sorry, I had a hard time to understand your needs. Maybe instead of allowing the value zero we better add a checkbox labeled hide the link title that would take care of the behavior you want.

I see it is a really good feature and IMHO it seems clear to end users this way.

mac_weber’s picture

Title: Allow 'Trim link text length' to be 0 (zero) » Allow hiding the link title as a field formatter option
Issue summary: View changes

Updated issue with my proposed solution.

mac_weber’s picture

Issue summary: View changes

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

felribeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

New implementation following @Mac_Weber proposed solution.

Status: Needs review » Needs work

The last submitted patch, 20: edit_allow_hiding_the-2641228-20.patch, failed testing.

The last submitted patch, 20: edit_allow_hiding_the-2641228-20.patch, failed testing.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for sharing your idea for improving Drupal.

We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

dcam’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

I'm not in favor of making this change. This feature is too much of an edge case to be included in Drupal Core. If you want to display links without titles, then create a new field formatter that makes links without titles. Then that formatter can be selected on a per-display basis as noted in #15.

Credit has been granted to those who worked on patches.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.