l

includes/common.inc, line 1394

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/content/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/content/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

▾ 104 functions call l()

aggregator_block in modules/aggregator/aggregator.module
Implementation of hook_block().
aggregator_form_category_submit in modules/aggregator/aggregator.module
Process aggregator_form_category form submissions. @todo Add delete confirmation dialog.
aggregator_form_feed_submit in modules/aggregator/aggregator.module
Process aggregator_form_feed form submissions. @todo Add delete confirmation dialog.
aggregator_view in modules/aggregator/aggregator.module
block_admin_display in modules/block/block.module
Generate main block administration form.
blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi/blogapi.module
Blogging API callback. Inserts a new blog post as a node.
blog_block in modules/blog/blog.module
Implementation of hook_block().
blog_form in modules/blog/blog.module
Implementation of hook_form().
blog_page_user in modules/blog/blog.module
Displays a Drupal page containing recent blog entries of a given user.
blog_user in modules/blog/blog.module
Implementation of hook_user().
book_admin_edit_submit in modules/book/book.module
book_admin_overview in modules/book/book.module
Returns an administrative overview of all books.
book_render in modules/book/book.module
Menu callback; prints a listing of all books.
book_tree_recurse in modules/book/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/comment.module
comment_admin_overview_submit in modules/comment/comment.module
Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
confirm_form in modules/system/system.module
Output a confirmation form
contact_admin_categories in modules/contact/contact.module
Categories/list tab.
contact_admin_edit_submit in modules/contact/contact.module
Process the contact category edit page form submission.
fileupload_view in developer/examples/fileupload.module
Implementation of hook_view.
filter_admin_format_form in modules/filter/filter.module
Generate a filter format form.
filter_admin_overview in modules/filter/filter.module
Displays a list of all input formats and which one is the default
forum_block in modules/forum/forum.module
Implementation of hook_block().
forum_overview in modules/forum/forum.module
Returns an overview list of existing forums and containers
help_links_as_list in modules/help/help.module
hook_requirements in developer/hooks/install.php
Check installation requirements that need to be satisfied.
menu_edit_item_form in modules/menu/menu.module
Present the menu item editing form.
menu_edit_item_save in modules/menu/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/menu.module
Present the menu tree, rendered along with links to edit menu items.
menu_overview_tree_rows in modules/menu/menu.module
node_add in modules/node/node.module
Present a node submission form or a set of links to such forms.
node_admin_nodes in modules/node/node.module
node_feed in modules/node/node.module
A generic function for generating RSS feeds from a set of nodes.
node_form_submit in modules/node/node.module
node_overview_types in modules/node/content_types.inc
Displays the content type admin overview page.
node_preview in modules/node/node.module
Generate a node preview.
node_revision_overview in modules/node/node.module
Generate an overview table of older revisions of a node.
node_title_list in modules/node/node.module
Gather a listing of links to nodes.
node_type_form_submit in modules/node/content_types.inc
Implementation of hook_form_submit().
path_overview in modules/path/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/poll.module
profile_admin_overview in modules/profile/profile.module
Menu callback; display a listing of all editable profile fields.
profile_block in modules/profile/profile.module
Implementation of hook_block().
profile_field_delete_submit in modules/profile/profile.module
Process a field delete form submission.
profile_field_form_submit in modules/profile/profile.module
Process profile_field_form submissions.
profile_view_field in modules/profile/profile.module
search_view in modules/search/search.module
Menu callback; presents the search form and/or search results.
statistics_access_log in modules/statistics/statistics.module
statistics_node_tracker in modules/statistics/statistics.module
statistics_recent_hits in modules/statistics/statistics.module
Menu callback; presents the "recent hits" page.
statistics_top_visitors in modules/statistics/statistics.module
Menu callback; presents the "top visitors" page.
statistics_user_tracker in modules/statistics/statistics.module
system_admin_by_module in modules/system/system.module
Menu callback; prints a listing of admin tasks for each installed module.
system_get_module_admin_tasks in modules/system/system.module
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
system_themes in modules/system/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/taxonomy.module
taxonomy_form_term_submit in modules/taxonomy/taxonomy.module
Accept the form submission for a taxonomy term and save the result.
taxonomy_form_vocabulary_submit in modules/taxonomy/taxonomy.module
Accept the form submission for a vocabulary and save the results.
taxonomy_overview_terms in modules/taxonomy/taxonomy.module
Display a tree of all the terms in a vocabulary, with options to edit each one.
taxonomy_overview_vocabularies in modules/taxonomy/taxonomy.module
List and manage vocabularies.
theme_admin_block_content in modules/system/system.module
This function formats the content of an administrative block.
theme_admin_page in modules/system/system.module
This function formats an administrative page for viewing.
theme_aggregator_block_item in modules/aggregator/aggregator.module
Format an individual feed item for display in the block.
theme_aggregator_feed in modules/aggregator/aggregator.module
Format a news feed.
theme_aggregator_page_item in modules/aggregator/aggregator.module
Format an individual feed item for display on the aggregator page.
theme_book_admin_table in modules/book/book.module
theme_book_navigation in modules/book/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/comment.module
theme_comment_block in modules/comment/comment.module
Returns a formatted list of recent comments to be displayed in the comment block.
theme_comment_folded in modules/comment/comment.module
theme_filter_tips_more_info in modules/filter/filter.module
theme_forum_display in modules/forum/forum.module
Format the forum body.
theme_forum_list in modules/forum/forum.module
Format the forum listing.
theme_forum_topic_list in modules/forum/forum.module
Format the topic listing.
theme_forum_topic_navigation in modules/forum/forum.module
Format the next/previous forum topic navigation links.
theme_links in includes/theme.inc
Return a themed set of 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_menu_links in includes/menu.inc
Returns the themed HTML for primary and secondary links. Note that this function is overridden by most core themes because those themes display links in "link | link" format, not from a list. Also note that by default links rendered with...
theme_pager_link in includes/pager.inc
Format a link to a specific query result page.
theme_upload_attachments in modules/upload/upload.module
Displays file attachments in table
theme_username in includes/theme.inc
Format a username.
theme_user_admin_new_role in modules/user/user.module
theme_user_picture in modules/user/user.module
tracker_page in modules/tracker/tracker.module
Menu callback. Prints a listing of active nodes on the site.
user_admin_access in modules/user/user.module
Menu callback: list all access rules
user_admin_account in modules/user/user.module
user_authenticate in modules/user/user.module
user_auth_help_links in modules/user/user.module
user_login_block in modules/user/user.module
user_register_submit in modules/user/user.module
watchdog_event in modules/watchdog/watchdog.module
Menu callback; displays details about a log message.
watchdog_overview in modules/watchdog/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/statistics.module
It is possible to adjust the width of columns generated by the statistics module.

Code

<?php
function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
  if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page())) {
    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>';
}
?>
 
 

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.