url

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 url($path = NULL, $options = array())
drupal7 url($path = NULL, array $options = array())

Generate a URL from a Drupal menu path. Will also pass-through existing URLs.

Übergabeparameter

$path The Drupal path being linked to, such as "admin/content/node", or an existing URL like "http://drupal.org/". The special path '<front>' may also be given and will generate the site's base URL.

$options An associative array of additional options, with the following keys:

  • 'query' A query string to append to the link, or an array of query key/value properties.
  • 'fragment' A fragment identifier (or named anchor) to append to the link. Do not include the '#' character.
  • 'absolute' (default FALSE) 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.
  • 'alias' (default FALSE) Whether the given path is an alias already.
  • 'external' Whether the given path is an external URL.
  • 'language' An optional language object. Used to build the URL to link to and look up the proper alias for the link.
  • 'base_url' Only used internally, to modify the base URL when a language dependent URL requires so.
  • 'prefix' Only used internally, to modify the path when a language dependent URL requires so.

Rückgabewert

A string containing a URL to the given path.

When creating links in modules, consider whether l() could be a better alternative than url().

▾ 185 functions call url()

AddFeedTestCase::testAddFeed in modules/aggregator/aggregator.test
Create a feed, ensure that it is unique, check the source, and delete the feed.
aggregator_block_view in modules/aggregator/aggregator.module
Implementation of hook_block_view().
aggregator_form_aggregator_admin_form_alter in modules/aggregator/aggregator.processor.inc
Implementation of hook_form_aggregator_admin_form_alter().
aggregator_form_feed in modules/aggregator/aggregator.admin.inc
Form builder; Generate a form to add/edit feed sources.
aggregator_form_opml in modules/aggregator/aggregator.admin.inc
Form builder; Generate a form to import feeds from OPML.
aggregator_help in modules/aggregator/aggregator.module
Implementation of hook_help().
aggregator_page_categories in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the categories used by the aggregator.
aggregator_page_category in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator/aggregator.pages.inc
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_sources in modules/aggregator/aggregator.pages.inc
Menu callback; displays all the feeds used by the aggregator.
batch_process in includes/form.inc
Process the batch.
block_admin_display_form in modules/block/block.admin.inc
Generate main blocks administration form.
block_box_form in modules/block/block.module
Define the custom block form.
block_help in modules/block/block.module
Implementation of hook_help().
BlogAPITestCase::testBlogAPI in modules/blogapi/blogapi.test
Create, edit, and delete post; upload file; set/get categories.
blogapi_blogger_get_users_blogs in modules/blogapi/blogapi.module
Blogging API callback. Finds the URL of a user's blog.
blogapi_blogger_get_user_info in modules/blogapi/blogapi.module
Blogging API callback. Returns profile information about a user.
blogapi_help in modules/blogapi/blogapi.module
Implementation of hook_help().
blogapi_init in modules/blogapi/blogapi.module
Implementation of hook_init().
blogapi_rsd in modules/blogapi/blogapi.module
blogapi_update_6000 in modules/blogapi/blogapi.install
Inform users about the new permission.
blog_block_view in modules/blog/blog.module
Implementation of hook_block_view().
blog_feed_last in modules/blog/blog.pages.inc
Menu callback; displays an RSS feed containing recent blog entries of all users.
blog_feed_user in modules/blog/blog.pages.inc
Menu callback; displays an RSS feed containing recent blog entries of a given user.
blog_help in modules/blog/blog.module
Implementation of hook_help().
blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
BookTestCase::checkBookNode in modules/book/book.test
Check the outline of sub-pages; previous, up, and next; and printer friendly version.
book_help in modules/book/book.module
Implementation of hook_help().
color_form_system_theme_settings_alter in modules/color/color.module
Implementation of hook_form_FORM_ID_alter().
color_help in modules/color/color.module
Implementation of hook_help().
CommentRSSUnitTest::testCommentRSS in modules/comment/comment.test
Test comments as part of an RSS feed.
comment_form in modules/comment/comment.module
Generate the basic commenting form, for appending to a node or display on a separate page.
comment_form_node_type_form_alter in modules/comment/comment.module
Implementation of hook_form_FORM_ID_alter().
comment_help in modules/comment/comment.module
Implementation of hook_help().
comment_node_view in modules/comment/comment.module
An implementation of hook_node_view().
CommonLUnitTest::testLXSS in modules/simpletest/tests/common.test
Confirm that invalid text given as $path is filtered.
contact_help in modules/contact/contact.module
Implementation of hook_help().
contact_mail in modules/contact/contact.module
Implementation of hook_mail().
contact_personal_page in modules/contact/contact.pages.inc
Personal contact page.
contact_site_page in modules/contact/contact.pages.inc
Site-wide contact page.
contact_user_form in modules/contact/contact.module
Implementation of hook_user_form().
dblog_form_system_logging_settings_alter in modules/dblog/dblog.admin.inc
Implementation of hook_form_FORM_ID_alter().
drupalGet in modules/simpletest/drupal_web_test_case.php
Retrieves a Drupal path or an absolute path.
drupalHead in modules/simpletest/drupal_web_test_case.php
Retrieves only the headers for a Drupal path or an absolute path.
DrupalHTTPRequestTestCase::testDrupalGetDestination in modules/simpletest/tests/common.test
DrupalHTTPRequestTestCase::testDrupalHTTPRequest in modules/simpletest/tests/common.test
DrupalHTTPRequestTestCase::testDrupalHTTPRequestBasicAuth in modules/simpletest/tests/common.test
DrupalHTTPRequestTestCase::testDrupalHTTPRequestRedirect in modules/simpletest/tests/common.test
drupal_goto in includes/common.inc
Send the user to a different Drupal page.
FieldFormTestCase::_fieldPostAhah in modules/field/field.test
Execute a POST request on a AHAH callback.
file_create_url in includes/file.inc
Create the download path to a file.
filter_help in modules/filter/filter.module
Implementation of hook_help().
form_process_ahah in includes/form.inc
Add AHAH information about a form element to the page to communicate with javascript. If #ahah[path] is set on an element, this additional javascript is added to the page header to attach the AHAH behaviors. See ahah.js for more information.
forum_block_view in modules/forum/forum.module
Implementation of hook_block_view().
forum_confirm_delete in modules/forum/forum.admin.inc
Returns a confirmation page for deleting a forum taxonomy term.
forum_help in modules/forum/forum.module
Implementation of hook_help().
forum_overview in modules/forum/forum.admin.inc
Returns an overview list of existing forums and containers
getAbsoluteUrl in modules/simpletest/drupal_web_test_case.php
Takes a path and returns an absolute path.
HookBootExitTestCase::testHookBootExit in modules/simpletest/tests/bootstrap.test
Test calling of hook_boot() and hook_exit().
hook_help in modules/help/help.api.php
Provide online user help.
hook_mail in modules/system/system.api.php
Prepare a message based on parameters.
hook_requirements in modules/system/system.api.php
Check installation requirements and do status reporting.
hook_search in modules/search/search.api.php
Define a custom search routine.
install_tasks in ./install.php
Tasks performed after the database is initialized.
l in includes/common.inc
Format an internal Drupal link.
LanguageSwitchingFunctionalTest::testLanguageBlock in modules/locale/locale.test
Functional tests for the language switcher block.
LocaleConfigurationTest::testLanguageConfiguration in modules/locale/locale.test
Functional tests for adding, editing and deleting languages.
LocaleImportFunctionalTest::testStandalonePoFile in modules/locale/locale.test
Test importation of standalone .po files.
LocaleTranslationFunctionalTest::testStringTranslation in modules/locale/locale.test
Adds a language and tests string translation by users with the appropriate permissions.
locale_form_node_type_form_alter in modules/locale/locale.module
Implementation of hook_form_FORM_ID_alter().
locale_help in modules/locale/locale.module
Implementation of hook_help().
locale_languages_predefined_form_submit in includes/locale.inc
Process the language addition form submission.
menu_get_active_help in includes/menu.inc
Returns the help associated with the active menu item.
menu_help in modules/menu/menu.module
Implementation of hook_help().
node_block_view in modules/node/node.module
Implementation of hook_block_view().
node_feed in modules/node/node.module
A generic function for generating RSS feeds from a set of nodes.
node_help in modules/node/node.module
Implementation of hook_help().
node_page_default in modules/node/node.module
Menu callback; Generate a listing of promoted nodes.
node_search in modules/node/node.module
Implementation of hook_search().
OpenIDFunctionalTest::testDelete in modules/openid/openid.test
Test deleting an OpenID identity from a user's profile.
OpenIDFunctionalTest::testDiscovery in modules/openid/openid.test
Test discovery of OpenID Provider Endpoint via Yadis and HTML.
OpenIDFunctionalTest::testLogin in modules/openid/openid.test
Test login using OpenID.
OpenIDFunctionalTest::testRegisterUserWithoutEmailVerification in modules/openid/openid.test
Test openID auto-registration with e-mail verification disabled.
openid_authentication in modules/openid/openid.module
Authenticate a user or attempt registration.
openid_authentication_request in modules/openid/openid.module
openid_help in modules/openid/openid.module
Implementation of hook_help().
openid_login_validate in modules/openid/openid.module
Login form _validate hook
openid_test_html_openid1 in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with OpenID 1.0 <link> element.
openid_test_html_openid2 in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with OpenID 2.0 <link> element.
openid_test_yadis_http_equiv in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with <meta> element.
openid_test_yadis_xrds in modules/openid/tests/openid_test.module
Menu callback; XRDS document that references the OP Endpoint URL.
openid_test_yadis_x_xrds_location in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with an X-XRDS-Location HTTP header.
openid_user_add_validate in modules/openid/openid.pages.inc
PageEditTestCase::testPageEdit in modules/node/node.test
Check node edit functionality.
PathLanguageTestCase::testAliasTranslation in modules/path/path.test
Test alias functionality through the admin interfaces.
path_admin_form in modules/path/path.admin.inc
Return a form for editing or creating an individual URL alias.
php_filter_tips in modules/php/php.module
Implementation of hook_filter_tips().
php_help in modules/php/php.module
Implementation of hook_help().
PollJSAddChoice::testAddChoice in modules/poll/poll.test
Test adding a new choice.
poll_help in modules/poll/poll.module
Implementation of hook_help().
ProfileTestAutocomplete::testAutocomplete in modules/profile/profile.test
Tests profile field autocompletion and access.
profile_block_configure in modules/profile/profile.module
Implementation of hook_block_configure().
profile_field_delete in modules/profile/profile.admin.inc
Menu callback; deletes a field from all user profiles.
RemoveFeedItemTestCase::testRemoveFeedItem in modules/aggregator/aggregator.test
Test running "remove items" from the 'admin/content/aggregator' page.
search_admin_settings in modules/search/search.admin.inc
Menu callback; displays the search module settings page.
search_form in modules/search/search.module
Render a search form.
search_help in modules/search/search.module
Implementation of hook_help().
SimpleTestFunctionalTest::getTestResults in modules/simpletest/simpletest.test
Get the results from a test and store them in the class array $results.
simpletest_help in modules/simpletest/simpletest.module
Implementation of hook_help().
simpletest_requirements in modules/simpletest/simpletest.install
Check that the cURL extension exists for PHP.
simpletest_result_form in modules/simpletest/simpletest.pages.inc
Test results form for $test_id.
statistics_access_log in modules/statistics/statistics.admin.inc
Menu callback; Displays recent page accesses.
statistics_help in modules/statistics/statistics.module
Implementation of hook_help().
statistics_settings_form in modules/statistics/statistics.admin.inc
Form builder; Configure access logging.
syslog_form_system_logging_settings_alter in modules/syslog/syslog.module
Implementation of hook_form_FORM_ID_alter().
syslog_help in modules/syslog/syslog.module
Implementation of hook_help().
system_check_http_request in modules/system/system.module
Checks whether the server is capable of issuing HTTP requests.
system_help in modules/system/system.module
Implementation of hook_help().
system_image_toolkit_settings in modules/system/system.admin.inc
Form builder; Configure site image toolkit usage.
system_mail in modules/system/system.module
Implementation of hook_mail().
system_main_admin_page in modules/system/system.admin.inc
Menu callback; Provide the administration overview page.
system_message_action in modules/system/system.module
A configurable Drupal action. Sends a message to the current user's screen.
system_modules in modules/system/system.admin.inc
Menu callback; provides module enable/disable interface.
system_modules_uninstall in modules/system/system.admin.inc
Builds a form of currently disabled modules.
system_regional_settings in modules/system/system.admin.inc
Form builder; Configure the site date and time settings.
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
system_site_information_settings in modules/system/system.admin.inc
Form builder; The general site information form.
system_site_maintenance_mode in modules/system/system.admin.inc
Form builder; Configure the site's maintenance status.
system_test_redirect in modules/simpletest/tests/system_test.module
system_themes_form_submit in modules/system/system.admin.inc
Process system_themes_form form submissions.
system_update_6017 in modules/system/system.install
Rename settings related to user.module email notifications.
system_update_6026 in modules/system/system.install
Display warning about new Update status module.
system_update_6045 in modules/system/system.install
Update blog, book and locale module permissions.
system_update_7021 in modules/system/system.install
Add new blocks to new regions, migrate custom variables to blocks.
system_user_login in modules/system/system.module
Implementation of hook_user_login().
taxonomy_node_view in modules/taxonomy/taxonomy.module
An implementation of hook_node_view().
taxonomy_term_page in modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.
template_preprocess_aggregator_feed_source in modules/aggregator/aggregator.pages.inc
Process variables for aggregator-feed-source.tpl.php.
template_preprocess_aggregator_item in modules/aggregator/aggregator.pages.inc
Process variables for aggregator-item.tpl.php.
template_preprocess_book_navigation in modules/book/book.module
Process variables for book-navigation.tpl.php.
template_preprocess_forums in modules/forum/forum.module
Process variables for forums.tpl.php
template_preprocess_forum_list in modules/forum/forum.module
Process variables to format a forum listing.
template_preprocess_forum_topic_list in modules/forum/forum.module
Preprocess variables to format the topic listing.
template_preprocess_forum_topic_navigation in modules/forum/forum.module
Preprocess variables to format the next/previous forum topic navigation links.
template_preprocess_maintenance_page in includes/theme.maintenance.inc
The variables generated here is a mirror of template_preprocess_page(). This preprocessor will run it's course when theme_maintenance_page() is invoked. It is also used in theme_install_page() and theme_update_page() to keep all the variables…
template_preprocess_node in modules/node/node.module
Process variables for node.tpl.php
template_preprocess_page in includes/theme.inc
Process variables for page.tpl.php
theme_aggregator_page_rss in modules/aggregator/aggregator.pages.inc
Theme the RSS output.
theme_comment_post_forbidden in modules/comment/comment.module
Theme a "you can't post comments" notice.
theme_image in includes/theme.inc
Return a themed image.
theme_textfield in includes/form.inc
Format a textfield.
TranslationTestCase::addLanguage in modules/translation/translation.test
Install a the specified language if it has not been already. Otherwise make sure that the language is enabled.
translation_form_node_type_form_alter in modules/translation/translation.module
Implementation of hook_form_FORM_ID_alter().
translation_help in modules/translation/translation.module
Implementation of hook_help().
trigger_help in modules/trigger/trigger.module
Implementation of hook_help().
UpdateFeedTestCase::testUpdateFeed in modules/aggregator/aggregator.test
Create a feed and attempt to update it.
update_help in modules/update/update.module
Implementation of hook_help().
update_mail in modules/update/update.module
Implementation of hook_mail().
update_settings in modules/update/update.settings.inc
Form builder for the update settings tab.
upload_admin_settings in modules/upload/upload.admin.inc
Menu callback for the upload settings form.
upload_form_alter in modules/upload/upload.module
upload_help in modules/upload/upload.module
Implementation of hook_help().
user_admin_settings in modules/user/user.admin.inc
Form builder; Configure user settings for this site.
user_cancel_url in modules/user/user.module
Generate a URL to confirm an account cancellation request.
user_help in modules/user/user.module
Implementation of hook_help().
user_login_block in modules/user/user.module
user_login_final_validate in modules/user/user.module
A validate handler on the login form. Should be the last validator. Sets an error if user has not been authenticated yet.
user_mail_tokens in modules/user/user.module
Return an array of token to value mappings for user e-mail messages.
user_pass_reset in modules/user/user.pages.inc
Menu callback; process one time login link and redirects to the user page on success.
user_pass_reset_url in modules/user/user.module
user_perm in modules/user/user.module
Implementation of hook_perm().
user_register_submit in modules/user/user.module
Submit handler for the user registration form.
user_search in modules/user/user.module
Implementation of hook_search().
user_user_validate in modules/user/user.module
Implementation of hook_user_validate().
XMLRPCMessagesTestCase::testSizedMessages in modules/simpletest/tests/xmlrpc.test
Make sure that XML-RPC can transfer large messages.
XMLRPCValidator1IncTestCase::testValidator1 in modules/simpletest/tests/xmlrpc.test
Run validator1 tests.
_batch_progress_page_js in includes/batch.inc
Output a batch processing page with JavaScript support.
_batch_progress_page_nojs in includes/batch.inc
Output a batch processing page without JavaScript support.
_blogapi_get_post in modules/blogapi/blogapi.module
_menu_site_is_offline in includes/menu.inc
Checks whether the site is offline for maintenance.
_openid_test_endpoint_authenticate in modules/openid/tests/openid_test.module
OpenID endpoint; handle "authenticate" requests.
_openid_user_login_form_alter in modules/openid/openid.module
_update_message_text in modules/update/update.module
Helper function to return the appropriate message text when the site is out of date or missing a security update.
_update_no_data in modules/update/update.module
Prints a warning message when there is no data about available updates.

Code

includes/common.inc, line 1947

<?php
function url($path = NULL, array $options = array()) {
  // Merge in defaults.
  $options += array(
    'fragment' => '',
    'query' => '',
    'absolute' => FALSE,
    'alias' => FALSE,
    'prefix' => ''
  );
  if (!isset($options['external'])) {
    // Return an external link if $path contains an allowed absolute URL.
    // Only call the slow filter_xss_bad_protocol if $path contains a ':' before
    // any / ? or #.
    $colonpos = strpos($path, ':');
    $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path));
  }

  // May need language dependent rewriting if language.inc is present.
  if (function_exists('language_url_rewrite')) {
    language_url_rewrite($path, $options);
  }
  if ($options['fragment']) {
    $options['fragment'] = '#' . $options['fragment'];
  }
  if (is_array($options['query'])) {
    $options['query'] = drupal_query_string_encode($options['query']);
  }

  if ($options['external']) {
    // Split off the fragment.
    if (strpos($path, '#') !== FALSE) {
      list($path, $old_fragment) = explode('#', $path, 2);
      if (isset($old_fragment) && !$options['fragment']) {
        $options['fragment'] = '#' . $old_fragment;
      }
    }
    // Append the query.
    if ($options['query']) {
      $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $options['query'];
    }
    // Reassemble.
    return $path . $options['fragment'];
  }

  global $base_url;
  static $script;

  if (!isset($script)) {
    // On some web servers, such as IIS, we can't omit "index.php". So, we
    // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
    // Apache.
    $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === FALSE) ? 'index.php' : '';
  }

  if (!isset($options['base_url'])) {
    // The base_url might be rewritten from the language rewrite in domain mode.
    $options['base_url'] = $base_url;
  }

  // Preserve the original path before aliasing.
  $original_path = $path;

  // The special path '<front>' links to the default front page.
  if ($path == '<front>') {
    $path = '';
  }
  elseif (!empty($path) && !$options['alias']) {
    $path = drupal_get_path_alias($path, isset($options['language']) ? $options['language']->language : '');
  }

  if (function_exists('custom_url_rewrite_outbound')) {
    // Modules may alter outbound links by reference.
    custom_url_rewrite_outbound($path, $options, $original_path);
  }

  $base = $options['absolute'] ? $options['base_url'] . '/' : base_path();
  $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
  $path = drupal_urlencode($prefix . $path);

  if (variable_get('clean_url', '0')) {
    // With Clean URLs.
    if ($options['query']) {
      return $base . $path . '?' . $options['query'] . $options['fragment'];
    }
    else {
      return $base . $path . $options['fragment'];
    }
  }
  else {
    // Without Clean URLs.
    $variables = array();
    if (!empty($path)) {
      $variables[] = 'q=' . $path;
    }
    if (!empty($options['query'])) {
      $variables[] = $options['query'];
    }
    if ($query = join('&', $variables)) {
      return $base . $script . '?' . $query . $options['fragment'];
    }
    else {
      return $base . $options['fragment'];
    }
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen