Active
Project:
Link
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Feb 2013 at 17:25 UTC
Updated:
8 Oct 2020 at 20:50 UTC
Jump to comment: Most recent
Hello,
I'm trying to display link fields, and I need url and title separately.
If the title (optional) isn't filled in, Link module puts the url in place of the title.
But how to know if the title has been filled in or not, from a node template?
I can't find a way to check the real value of the title field.
Any idea?
Thanks!
Comments
Comment #1
jcfiala commentedWell, I'm not sure if this is a _bug_, actually, but that's a good point. Hm.
What if I returned some sort of 'title_status' field... or entered_title... thoughts?
Comment #2
jcfiala commentedYou know, I think I might try returning an "original_title" and "original_url" fields, so themers can get at the original values if they __really__ want to... But willing to entertain feedback.
Comment #3
ludo.rIn fact, I have a link field with optional title.
If the user fills in the title, then we display the title value.
If the user doesn't fill in the title, then we have to display "Read article", and it must be translated (so field's default value doesn't meet requirements).
"original_title" and "original_url" (?), seem to be a decent solution.
Comment #4
jcfiala commentedI'm thinking of combining this with #1475790: Link should not modify $item['url'] on node_view() (causes data loss when combined with Workbench Moderation), so that would mean actually going to creating new url/title/attribute fields for the themes to hook off of, and leaving the original url/title as is.
However, that's a bit of whiplash for existing theme functions. I'm thinking if I'm doing something this radical to how the field is themed, it should be part of moving to 7.x-2.0 version.
Comment #5
mile23I'm going to call this a bug, since there is a common use-case where you wrap a link around a div that has an image, to provide a 'button' or what-have-you.
In that case, you'd want to leave the URL in place of the title for accessibility reasons, but be able to style the title text to hide it.
If someone wanted to do this, they'd alter
theme_link_formatter_link_default()so that if there was no title field value, the link options attributes would contain a class called something like 'link-without-title'.Then they'd write a test which adds a link with no title, and checks that it has the class added by
l().Adding Novice tag.
Comment #6
mile23Just a heads-up: You can find the original title in the helpful original_title field.