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
  • 3
    When displayed, the menu link will use the defined path alias. Any reason why this isn't enough?
    – Berdir
    Commented Apr 14, 2011 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
    Commented Apr 14, 2011 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
    Commented Jun 15, 2011 at 20:48

6 Answers 6

7

As Berdir mentioned in the comments and Greg 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 the Pathauto module to automatically create path aliases
  • Manually adding path aliases on Configuration → Search and metadata → URL aliases

Try clearing the cache from Configuration → Development → Performance. This should rebuild Drupal's menus and correctly show the path aliases.

0
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
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.

3
  • 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
    Commented Apr 14, 2011 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
    Commented Apr 14, 2011 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
    Commented Apr 14, 2011 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.

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