Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
link
Commits
830f1f54
Commit
830f1f54
authored
Apr 16, 2007
by
Nathan Haug
Browse files
Adding formatter which displays the title as the label of the widget. Issue #135047. Thanks sarvab!
parent
b85607b2
Changes
1
Show whitespace changes
Inline
Side-by-side
link.module
View file @
830f1f54
...
...
@@ -460,6 +460,10 @@ function link_field_formatter_info() {
'label'
=>
t
(
'Short, as link with title "Link"'
),
'field types'
=>
array
(
'link'
),
),
'label'
=>
array
(
'label'
=>
t
(
'Label, as link with label as title'
),
'field types'
=>
array
(
'link'
),
),
);
}
...
...
@@ -512,10 +516,15 @@ function link_field_formatter($field, $item, $formatter, $node) {
if
(
$formatter
==
'short'
)
{
$output
=
l
(
t
(
'Link'
),
$url
,
$attributes
,
$query
,
$fragment
);
}
// Build the link using the widget label
elseif
(
$formatter
==
'label'
)
{
$output
=
l
(
t
(
$field
[
'widget'
][
'label'
]),
$url
,
$attributes
,
$query
,
$fragment
);
}
// Build the link with a title
elseif
(
strlen
(
trim
(
$item
[
'title'
])))
{
$output
=
l
(
$item
[
'title'
],
$url
,
$attributes
,
$query
,
$fragment
);
}
// Build the link with the URL or email address as the title (max 80 characters)
else
{
$display_url
=
$type
==
LINK_EMAIL
?
str_replace
(
'mailto:'
,
''
,
$url
)
:
url
(
$url
,
$query
,
$fragment
,
TRUE
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment