Currently, urls that use the url_alias table do not allow arguments. This is not desirable because it is useful to be able to specify arguments on a script that is aliased without having to refer to it by node number.

The code below replaces the drupal_get_normal_path() function in common.inc to allow aliased paths to have arguments.

/**                                                                                                                                                                                                                   
 * Given a path alias, return the internal path it represents.                                                                                                                                                        
 */
function drupal_get_normal_path($path) {
  if (($map = drupal_get_path_map()) && isset($map[$path])) {
    return $map[$path];
  }
  elseif (function_exists('conf_url_rewrite')) {
    return conf_url_rewrite($path, 'incoming');
  }
  else {
    //look at each of the path components of $path and allow extra components to be arguments                                                                                                                         
    //do a greedy search first for the largest paths                                                                                                                                                                  
    if ($map && (strpos($path, '/') !== false)) {
      $newpath = clone($path);
      $args = '';
      while($path_end = strrpos($newpath, '/')) {
        $args = substr($newpath, $path_end).$args;
        $newpath = substr($newpath, 0, $path_end);
        //check to see if this new path exists in the path map                                                                                                                                                        
        if(isset($map[$newpath])) {
          return $map[$newpath].$args;
        }
      }
    }

    //no alias was found, return the original path                                                                                                                                                                    
    return $path;
  }
}

Comments

Steven’s picture

First, I'm not sure if this is desirable. Without at least some examples it is hard to tell.

However, it seems to me that without similar changes in the path-to-alias conversion, we get very inconsistent path handling. I imagine you want to create links to argumented aliases yourself, but Drupal would only output identical aliases. This goes against the idea that URLs should be unique identifiers as much as possible.

Also please submit proper patches in unified diff format. Otherwise it is very hard to see what has changed. Take a look at Drupal's coding conventions too. And why are you calling clone() on a string? Strings are passed and assigned by value.

killes@www.drop.org’s picture

Version: 4.6.0 » x.y.z
Category: bug » feature
Status: Needs review » Active

It's a feature request, there is not patch, and new features go into cvs only.

ricabrantes’s picture

Version: x.y.z » 5.x-dev

This is active??

marcingy’s picture

Version: 5.x-dev » 8.x-dev

Bumping version

Dave Reid’s picture

Component: base system » path.module
Dave Reid’s picture

Status: Active » Closed (won't fix)

It's hard at all to tell what's going on here since core's changed so much. Please re-open with a re-clarification or search to see if someone has reported something similar.