1 theme.inc | theme_link($variables) |
Returns HTML for a link.
This is a wrapper around l() to allow for more flexible link theming.
Where performance is more important than theme flexibility, Backdrop code that outputs a link should call the l() function directly, as #theme 'link' implementations have a measurable performance impact.
Parameters
array $variables: An associative array containing the keys:
- text: The text of the link.
- path: The internal path or external URL being linked to. It is used as the $path parameter of the url() function.
- options: (optional) An array that defaults to empty, but can contain:
- attributes: Can contain optional attributes:
- class: must be declared in an array. Example: 'class' => array('class_name1','class_name2').
- title: must be a string. Example: 'title' => 'Example title'
- Others are more flexible as long as they work with backdrop_attributes($variables['options']['attributes]).
- html: Boolean flag that tells whether text contains html or plain text. If not set to TRUE the text value will be sanitized.
- attributes: Can contain optional attributes:
The elements $variables['options']['attributes'] and $variables['options']['html'] are used in this function similarly to the way that $options['attributes'] and $options['html'] are used in l(). The link itself is built by the url() function, which takes $variables['path'] and $variables['options'] as arguments.
See also
l()
url()
Related topics
File
- core/
includes/ theme.inc, line 1846 - The theme system, which controls the output of Backdrop.
Code
function theme_link($variables) {
$rendered_text = is_array($variables['text']) ? backdrop_render($variables['text']) : $variables['text'];
return l($rendered_text, $variables['path'], $variables['options']);
}