14

I am kicking the tires on Drupal 7 by spinning up a test site.

I chose the Danland theme and created various pages with URL Aliases for each, but when I create the Menu link for each, I can only enter the node in the "Path" field for the menu link and not the alias. So I can only enter "node/20" and not "about-us" (the alias for the node) in the menu.

I'd like the menu items to resolve to the aliases and not the nodes.
How do I do that?

  • 3
    When displayed, the menu link will use the defined path alias. Any reason why this isn't enough? – Berdir Apr 14 '11 at 15:19
  • Mine doesn't seem to be doing that. Not sure if I'm missing some config somewhere or what - see: reboot.researchvessels.org/about-us which works as an alias but I can't make the menu link go there. Path field only accepts external URLs or node refs. – cpuguru Apr 14 '11 at 15:25
  • I'm having the same problem. My "main menu" works fine with aliases. I created a new menu. This is the only that won't save aliases. Furthermore it breaks completely because when I go to "node/10" then I want to click on another page the menu links have an extra "node" so it is pointing to "node/node/10" "node/node/11" etc. If I use the absolute path then it will take me to the correct page but I want the menu to be able to automatically recognize which page is active, it doesn't recognize that the absolute URL is the path I'm on so the css class "active" isn't set properly. I have drupal 7.2 – user1645 Jun 15 '11 at 20:48
7

Like Berdir mentioned in the comments and Greg mentioned in his answer, the following methods of adding path aliases should Just Work™:

  • Adding it on the node submission form during node creation/editing
  • Using Pathauto to automatically create aliases for nodes.
  • Adding aliases manually by going to ConfigurationSearch and metadataURL aliases

That it's not doing that is weird. Try clearing your cache by going to ConfigurationDevelopmentPerformance. This should rebuild Drupal's menus and get the path aliases to show correctly.

  • 1
    I thought Global Redirect only affected url resolution, not link output? I use Global Redirect from the start on all my sites - I'm not sure how Drupal behaves without it. – Greg Apr 15 '11 at 4:40
  • @Greg you're correct; I added it as a possible workaround, but it doesn't really do anything to solve the core issue, so I removed it. – user7 Apr 15 '11 at 4:46
  • The aliases work, it's just that I can't enter the aliased path into the menu as the destination, only an external URL or "node/x". I can't tell it to go to "about-us" for the menu entry, only "node/20". So the question is, how can I go about entering the alias as the destination and not the node? – cpuguru Apr 16 '11 at 16:23
  • I cleared the cache and even deleted and re-created the About Us page and still no joy. – cpuguru Apr 16 '11 at 18:58
  • I just installed the Global Redirect module and still no luck - drupal.org/project/globalredirect – cpuguru Apr 17 '11 at 18:08
4

I could also be that you are browsing the site in a different language than the url alias was created for. If you create an alias while browsing in German (say), visitors browsing the site in English mode will still see node/234234 . Just a tip.

0

If you assign both the path alias and the menu entry using the node add/edit form, then the created menu items will use the aliased paths. For simple use cases you shouldn't need to manually create aliases on the admin/config/search/path page or manually create menu entries on the admin/structure/menu page.

  • I can create the aliases and they work if I go to them directly, but I can't find a way to configure the menu to use them. The only option available seems to be "node/xx" for the Path field, and when you click on the link it shows site/node/xx in the address field and not the URL alias. – cpuguru Apr 14 '11 at 19:56
  • @cpuguru - If you delete a node's alias and menu item, then recreate the alias and menu item from the node edit form, does the menu item still not use the alias? – Greg Apr 14 '11 at 20:18
  • No, I just tried again with the "Partnerships" page. Deleted the Alias and the menu item and then added the "Partnerships" page, adding the Alias and adding it to the Menu and it still shows up in the menu as "node/21". – cpuguru Apr 14 '11 at 20:55
0

I just tried with a new d7 installation using the Danland theme and it works properly. If you can't get it working you can always specify an external url in your menu right? Such as 'http://yourdomain.com/about-us' intead of 'node/1'

0

It appears that updating my Drupal install from Drupal 7 to the newly released Drupal 7.2 fixed the problem. It was either that or the updated SQL Server drivers that were just released which you'll need to install over the original PDO SQL Server drivers for the update scripts to work if you're updating to Drupal 7.2.

Either way, now the aliased URL shows up when I click on a menu link. So it could be either the code changes in Drupal core 7.2 OR the SQL Server driver updates. I am not 100% sure which one it is.

0

Theme templates can be overridden with URL alias in the following way.

  1. Add a preprocess function in theme template file
  2. Get the URL alias, and choose the template file

The full explanation with code is given in How to create a template for page created in drupal Admin with URL alias.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.