l

Versions
4.6 – 5
l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE)
6
l($text, $path, $options = array())
7
l($text, $path, array $options = array())

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.

Parameters

$text The text to be enclosed with the anchor tag.

$path The Drupal path being linked to, such as "admin/node". Can be an external or internal URL.

  • If you provide the full URL, it will be considered an

external URL.

  • If you provide only the path (e.g. "admin/node"), it is considered an

internal link. In this case, it must be a system URL as the url() function will generate the alias.

$attributes An associative array of HTML attributes to apply to the anchor tag.

$query A query string to append to the link.

$fragment A fragment identifier (named anchor) to append to the link.

$absolute Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.

$html Whether the title is HTML, or just plain-text. For example for making an image a link, this must be set to TRUE, or else you will see the encoded HTML.

Return value

an HTML string containing a link to the given path.

Related topics

▾ 110 functions call l()

aggregator_block in modules/aggregator.module
Implementation of hook_block().
aggregator_form_category_submit in modules/aggregator.module
Process aggregator_form_category form submissions. @todo Add delete confirmation dialog.
aggregator_form_feed_submit in modules/aggregator.module
Process aggregator_form_feed form submissions. @todo Add delete confirmation dialog.
aggregator_page_categories in modules/aggregator.module
Menu callback; displays all the categories used by the aggregator.
aggregator_page_sources in modules/aggregator.module
Menu callback; displays all the feeds used by the aggregator.
aggregator_view in modules/aggregator.module
archive_calendar in modules/archive.module
Generates a monthly calendar, for display in the archive block.
block_admin_display in modules/block.module
Generate main block administration form.
blogapi_blogger_edit_post in modules/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi.module
Blogging API callback. Inserts a new blog post as a node.
blog_block in modules/blog.module
Implementation of hook_block().
blog_form in modules/blog.module
Implementation of hook_form().
blog_link in modules/blog.module
Implementation of hook_link().
blog_page_user in modules/blog.module
Displays a Drupal page containing recent blog entries of a given user.
blog_user in modules/blog.module
Implementation of hook_user().
book_admin_edit_submit in modules/book.module
book_admin_overview in modules/book.module
Returns an administrative overview of all books.
book_link in modules/book.module
Implementation of hook_link().
book_render in modules/book.module
Menu callback; prints a listing of all books.
book_tree_recurse in modules/book.module
This is a helper function for book_tree()
chameleon_comment in themes/chameleon/chameleon.theme
chameleon_node in themes/chameleon/chameleon.theme
chameleon_page in themes/chameleon/chameleon.theme
comment_admin_overview in modules/comment.module
Menu callback; present an administrative comment listing.
comment_admin_overview_submit in modules/comment.module
Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.
comment_link in modules/comment.module
Implementation of hook_link().
comment_links in modules/comment.module
comment_save in modules/comment.module
Accepts a submission of new or changed comment content.
confirm_form in modules/system.module
contact_admin_categories in modules/contact.module
Categories/list tab.
contact_admin_edit_submit in modules/contact.module
Process the contact category edit page form submission.
drupal_access_denied in includes/common.inc
Generates a 403 error if the request is not allowed.
fileupload_view in developer/examples/fileupload.module
Implementation of hook_view.
filter_admin_format_form in modules/filter.module
Generate a filter format form.
filter_admin_overview in modules/filter.module
Displays a list of all input formats and which one is the default
filter_form in modules/filter.module
Generate a selector for choosing a format in a form.
forum_block in modules/forum.module
Implementation of hook_block().
forum_overview in modules/forum.module
Returns an overview list of existing forums and containers
help_links_as_list in modules/help.module
hook_link in developer/hooks/core.php
Define internal Drupal links.
image_gd_settings in includes/image.inc
Retrieve settings for the GD2 toolkit (not used).
menu_edit_item_form in modules/menu.module
Present the menu item editing form.
menu_edit_item_save in modules/menu.module
Save changes to a menu item into the database.
menu_get_active_breadcrumb in includes/menu.inc
Returns an array of rendered menu items in the active breadcrumb trail.
menu_overview_tree in modules/menu.module
Present the menu tree, rendered along with links to edit menu items.
menu_overview_tree_rows in modules/menu.module
menu_primary_links in includes/menu.inc
Returns an array containing the primary links. Can optionally descend from the root of the Primary links menu towards the current node for a specified number of levels and return that submenu. Used to generate a primary/secondary menu from different...
node_add in modules/node.module
Present a node submission form or a set of links to such forms.
node_admin_nodes in modules/node.module
Menu callback: content administration.
node_feed in modules/node.module
A generic function for generating RSS feeds from a set of nodes.
node_form_submit in modules/node.module
node_link in modules/node.module
Implementation of hook_link().
node_preview in modules/node.module
Generate a node preview.
node_revision_overview in modules/node.module
Generate an overview table of older revisions of a node.
node_title_list in modules/node.module
Gather a listing of links to nodes.
node_types_configure in modules/node.module
Menu callback; presents each node type configuration page.
path_overview in modules/path.module
Return a listing of all defined URL aliases.
phptemplate_comment in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_comment function to be passed into a pluggable template engine.
poll_page in modules/poll.module
poll_view in modules/poll.module
Implementation of hook_view().
profile_admin_overview in modules/profile.module
Menu callback; display a listing of all editable profile fields.
profile_block in modules/profile.module
Implementation of hook_block().
profile_field_delete_submit in modules/profile.module
Process a field delete form submission.
profile_field_form_submit in modules/profile.module
Process profile_field_form submissions.
profile_view_field in modules/profile.module
search_view in modules/search.module
Menu callback; presents the search form and/or search results.
statistics_access_log in modules/statistics.module
statistics_node_tracker in modules/statistics.module
statistics_recent_hits in modules/statistics.module
Menu callback; presents the "recent hits" page.
statistics_top_visitors in modules/statistics.module
Menu callback; presents the "top visitors" page.
statistics_user_tracker in modules/statistics.module
system_themes in modules/system.module
Menu callback; displays a listing of all themes.
tablesort_header in includes/tablesort.inc
Format a column header.
taxonomy_form_term in modules/taxonomy.module
taxonomy_link in modules/taxonomy.module
Implementation of hook_link().
taxonomy_overview_terms in modules/taxonomy.module
Display a tree of all the terms in a vocabulary, with options to edit each one.
taxonomy_overview_vocabularies in modules/taxonomy.module
List and manage vocabularies.
theme_aggregator_block_item in modules/aggregator.module
Format an individual feed item for display in the block.
theme_aggregator_feed in modules/aggregator.module
Format a news feed.
theme_aggregator_page_item in modules/aggregator.module
Format an individual feed item for display on the aggregator page.
theme_book_admin_table in modules/book.module
theme_book_navigation in modules/book.module
Prepares the links to children (TOC) and forward/backward navigation for a node presented as a book page.
theme_comment in modules/comment.module
theme_comment_block in modules/comment.module
theme_comment_folded in modules/comment.module
theme_forum_display in modules/forum.module
Format the forum body.
theme_forum_list in modules/forum.module
Format the forum listing.
theme_forum_topic_list in modules/forum.module
Format the topic listing.
theme_forum_topic_navigation in modules/forum.module
Format the next/previous forum topic navigation links.
theme_locale_admin_manage_screen in includes/locale.inc
Theme the locale admin manager form.
theme_menu_item_link in includes/menu.inc
Generate the HTML representing a given menu item ID.
theme_pager_link in includes/pager.inc
Format a link to a specific query result page.
theme_upload_attachments in modules/upload.module
Displays file attachments in table
theme_username in includes/theme.inc
Format a username.
theme_user_admin_new_role in modules/user.module
theme_user_picture in modules/user.module
tracker_page in modules/tracker.module
Menu callback. Prints a listing of active nodes on the site.
upload_link in modules/upload.module
Implementation of hook_link().
user_admin_access in modules/user.module
Menu callback: list all access rules
user_admin_account in modules/user.module
user_admin_perm in modules/user.module
Menu callback: administer permissions.
user_authenticate in modules/user.module
user_auth_help_links in modules/user.module
user_block in modules/user.module
Implementation of hook_block().
user_login_validate in modules/user.module
user_register_submit in modules/user.module
watchdog_event in modules/watchdog.module
Menu callback; displays details about a log message.
watchdog_overview in modules/watchdog.module
Menu callback; displays a listing of log messages.
_locale_string_seek in includes/locale.inc
Perform a string search and display results in a table
_statistics_link in modules/statistics.module
It is possible to adjust the width of columns generated by the statistics module.

Code

includes/common.inc, line 1120

<?php
function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
  if ($path == $_GET['q']) {
    if (isset($attributes['class'])) {
      $attributes['class'] .= ' active';
    }
    else {
      $attributes['class'] = 'active';
    }
  }
  return '<a href="'. check_url(url($path, $query, $fragment, $absolute)) .'"'. drupal_attributes($attributes) .'>'. ($html ? $text : check_plain($text)) .'</a>';
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.