url_alter_test_url_outbound_alter

Versions
7
url_alter_test_url_outbound_alter(&$path, &$options, $original_path)

Implements hook_url_outbound_alter().

Code

modules/simpletest/tests/url_alter_test.module, line 29

<?php
function url_alter_test_url_outbound_alter(&$path, &$options, $original_path) {
  // Rewrite user/uid to user/username.
  if (preg_match('!^user/([0-9]+)(/.*)?!', $path, $matches)) {
    if ($account = user_load($matches[1])) {
      $matches += array(2 => '');
      $path = 'user/' . $account->name . $matches[2];
    }
  }

  // Rewrite forum/ to community/.
  if ($path == 'forum' || strpos($path, 'forum/') === 0) {
    $path = 'community' . substr($path, 5);
  }
}
?>
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.