In v4.x and 5.x you could create a menu item "Foo" that pointed to an aliased URL "fred" which referred to node/x.
Then, if you later changed fred to point to node/y, everything in the system would work fine. All references to fred on pages would go to node/y and menu item Foo would also go to node/y.
In 6.x, this behavior was changed dramatically.
In 6.x, if you create menu item "Foo" and specify a path alias "fred" which points to node/x, you get a message saying that the menu system doesn't store aliases and that node/x would be saved as the url for Foo.
So, if you change the path alias, "fred", to point to node/y instead of node/x, references in pages to "fred" will go to node/y, but the menu item Foo will still point to node/x!
This design choice was not a good one because it dramatically impacts the usefulness of path aliases and the flexibility of the menu system.
I raised this as an issue for 6.x, but was told that the menu system was spec'd this was and that's that. Which I find surprising from a project that is generally quite responsive to inputs from users.
Thank you for considering this change.
Comments
Comment #1
uotonyh commentedI would like to know why this behavior was changed as well: Anyone have pointers to that information?
Thanks in advance!
Comment #2
uotonyh commentedQuery about
path.inc:Function
drupal_get_path_aliascallsdrupal_lookup_path. Ifdrupal_lookup_pathdoes not return false, why not use the alias? I must be missing something here.Thanks again!
Comment #3
pwolanin commentedyou are missing the fact that we store the router path in the {menu_links} table - which is derived form the real (no alias) path and which is critical for access checks, etc.
So, basically, to do what you suggest would be problematic in as much as when the alias changed, you'd have to update all the entries in {menu_links}. Possible, maybe, but it doesn't seem like a common use case. There are other ways to achieve the end you want - including a custom callback that does a drupal_goto(), or perhaps hook_translated_menu_link_alter().
Comment #4
xanoI think the menu system should save the aliases a certain item refers to. If an alias is being updated, the menu system should check if that alias is being used by a menu item. If not: live happily ever after. It is _is_ being edited, check if te destination is still the same. If not: rebuild the menu. If the alias itself has been changed, update the menu item and let it refer to the alias's destination rather than the alias itself.
Comment #5
j. ayen green commentedArchitecture issues aside (and I realize that's a large aside), being able to use path/alias EXCEPT with menu links is like being able to only make right-hand turns in the car, or only drive on roads named Street but not Avenue.
My clients ALL want their urls to be pretty and meaningful in the browser address bar. Having any link come up as ---/node/80 instead of the path alias is a major problem.
Comment #6
xano@baalwww: Global Redirect may be a temporary solution in your case.
Comment #7
sun.core commentedI agree with pwolanin.
URL aliases work on top of internal paths. They alias something. If you change the alias, then you don't change the path. If you want to change the path, then you need to change the path.