l($text, $path, array $options = array())
drupal/includes/common.inc, line 1631
Format an internal Drupal link.
This function correctly handles aliased paths, and allows themes to highlight links to the current page correctly, so all internal links output by modules should be generated by this function if possible.
$text The text to be enclosed with the anchor tag.
$path The Drupal path being linked to, such as "admin/content/node". Can be an external or internal URL.
an HTML string containing a link to the given path.
| Name | Description |
|---|---|
| Input validation | Functions to validate user input. |
function l($text, $path, array $options = array()) {
// Merge in defaults.
$options += array(
'attributes' => array(),
'html' => FALSE,
);
// Append active class.
if ($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) {
if (isset($options['attributes']['class'])) {
$options['attributes']['class'] .= ' active';
}
else {
$options['attributes']['class'] = 'active';
}
}
// Remove all HTML and PHP tags from a tooltip. For best performance, we act only
// if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
$options['attributes']['title'] = strip_tags($options['attributes']['title']);
}
return '<a href="' . check_url(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
}