[drupal-devel] [bug] patch: allow url_alias paths to have arguments
Issue status update for http://drupal.org/node/27206 Post a follow up: http://drupal.org/project/comments/add/27206 Project: Drupal Version: 4.6.0 Component: base system Category: bug reports Priority: normal Assigned to: jhenry Reported by: jhenry Updated by: jhenry Status: patch 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; } } jhenry
Issue status update for http://drupal.org/node/27206 Post a follow up: http://drupal.org/project/comments/add/27206 Project: Drupal Version: 4.6.0 Component: base system Category: bug reports Priority: normal Assigned to: jhenry Reported by: jhenry Updated by: Steven Status: patch 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. Steven Previous comments: ------------------------------------------------------------------------ Thu, 21 Jul 2005 15:39:01 +0000 : jhenry 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; } }
participants (2)
-
jhenry -
Steven