Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Steps to reproduce
1. Create a link field with Static Title and make URL optional
2. Add a node with the link field leaving URL empty, the static title will not show up
Comment | File | Size | Author |
---|---|---|---|
#28 | link_optional_url_static_title_with_tokens_revert_2553705_28.patch | 1.24 KB | pifagor |
| |||
#12 | link_optional_url_static_title_with_tokens_2553705_11.patch | 1.53 KB | aguilarm |
Comments
Comment #2
reshma.i CreditAttribution: reshma.i commentedThere might be a requirement like if you want to display default static title, But still yes! This is a issue. Uploaded patch is working for me.
Comment #3
Trav84 CreditAttribution: Trav84 as a volunteer commentedRerolled against dev. Added token replacement on title.
Comment #4
michaelfavia CreditAttribution: michaelfavia commentedTested and confirmed proper operation on 7.x. Any chance we could get this in for future versions of link module? Happy to revise patch or approach as needed with feedback. Thanks!
Comment #7
Trav84 CreditAttribution: Trav84 as a volunteer commentedRemoved function call from empty to support PHP versions prior to 5.5.
Comment #8
michaelfavia CreditAttribution: michaelfavia commentedReviewed patch. Syntax error fixed. php 5.3 compat now. RTBC
Comment #9
Trav84 CreditAttribution: Trav84 as a volunteer commentedSyntax error fixed.
Comment #10
aguilarm CreditAttribution: aguilarm commentedBit of adjusting, token_replace is escaping special chars and as a result this was rendering out & and things which is not intended. Ideally this should be in _link_sanitize probably.
Comment #12
aguilarm CreditAttribution: aguilarm commentedAdjusting the patch format
Comment #13
renatogHi people.
I applied the patch and work good for me.
+RTBC
Comment #15
renatogFixed.
Commited in dev branch.
Thank you all for contributions.
Good Work and Good Weekend.
Regards.
Comment #17
Bès CreditAttribution: Bès at Happyculture commentedThe static title is displayed even when the 'Optional URL' is not checked, this is a regression.
Can you please reopen the issue ?
Comment #18
HazaI know this is not a funny thing to do, but please, when you apply patches, please reroll them and post the patch here, then apply the same patch as the one posted here.
Applied patch is not the same as the one we have here : http://cgit.drupalcode.org/link/patch/?id=cb96589532d581cce6852eb06a3712...
Comment #19
vinmassaro CreditAttribution: vinmassaro commentedI reported this regression here: https://www.drupal.org/project/link/issues/2961210#comment-12586355
Comment #20
pifagorI reopen task
Comment #21
pifagorHello everyone
@vinmassaro, @Bès
The patch is working. We have to show the link title, even if there is no URL (if you have active option "Optional URL").
This is similar to the behavior of the link display when we have the "Optional URL" and "Optional Title" or "Required Title" or empty URL.
For example. In the version of the module 7.x-1.4, if we have the "Optional URL" and "Optional Title" active parameters and the empty URL, the header of the link is displayed.
The link should not be displayed when the active parameter is "No Title" and the empty field URL while saving the node.
I think we can close this issue.
Comment #22
pifagorComment #23
pifagorComment #24
vinmassaro CreditAttribution: vinmassaro commented@pifagor: thanks for reviewing. We have hundreds of sites using this module and when deploying out 7.x-1.5-beta3, behavior that was not expected started happening. There is a link field with a static title set. On a node where this field was empty, the field was not output, as expected. After updating to 7.x-1.5-beta3, the node began showing the static title as plain text, not linked to anything, because the field was empty. This doesn't seem to make sense to me. Why would I want the static title to appear as plain text when the actual link field is empty and there is nothing to link the static title to?
This patch seems to reverse default expected behavior of the Link module that has already been established for a long time (if the field is empty, don't display anything).
Comment #25
pifagor@vinmassaro
Try adding "Optional URL" and "Optional Title"
And at the same time save the link value without the URL. The link name will be available without the link itself.
This works the module independing on the version.
PS:
If this creates problems, we may remove this patch from version 1.5.
However, in version 1.6, we must include either the current behavior or not display the link at all if there is no URL.
Comment #26
pifagorComment #27
vinmassaro CreditAttribution: vinmassaro commented@pifagor: Thanks for the quick reply again. What is the use case of having an optional title with no link? Why would you want a plain text title to be output without being linked to something?
The issue here for us is that this changes the behavior of existing link fields. If you create a new link field and configure it just so, the title will not print out. But for an existing field with a static title that is empty, the update begins outputting the static title as plain text which is not the desired behavior. I imagine you will get new issues added to the issue queue if this becomes part of the release, since it can be seen as a bug for users updating the Link module. It would require manual reconfiguration of existing link fields in order to replicate the old behavior. This for us is not possible given we manage nearly ~1000 sites that use link fields all over the place.
Comment #28
pifagorHi @vinmassaro
Yes, of course, this is a problem.
I am adding the patch returns compatibility for version 7.x-1.5-beta3 and the problem will disappear.
In the following version, we will redesign this functionality.
@vinmassaro, please test the patch
Comment #29
vinmassaro CreditAttribution: vinmassaro commented@pifagor thanks, will get back to you on this patch.
Comment #30
vinmassaro CreditAttribution: vinmassaro commented@pifagor: Thank you, the patch seems to be working. I don't see the same unexpected behavior happen with the link fields when updating to 7.x-1.5-beta3 and applying the patch, but I also did not test the changes added by this patch.
Comment #31
pifagor@vinmassaro, done - https://cgit.drupalcode.org/link/commit/?id=90a59d3
Comment #32
pifagor