Posted by gallamine on April 10, 2009 at 2:30am
I'm using Pathauto to clean up the nasty Drupal URLs. So, I have a content type "project" and the URLs to these projects are like: /project/projectname
However, when I'm viewing that project, the "Edit", "What Links Here", and "Who's Bookmarked" links at the top is still linking to the old nasty Drupal urls, like "/node/175/edit".
Does anyone know of a way to change this? I can't seem to find any answers on the intertubes.
Comments
Good question
This got me sufficiently curious that I spent some time poking around in pathauto's CVS repository on Drupal.org. The following is taken from README.txt:
"Pathauto just adds URL aliases to nodes, users, and taxonomy terms. Because
it's an alias, the standard Drupal URL (for example node/123 or
taxonomy/term/1) will still function as normal. If you have external links
to your site pointing to standard Drupal URLs, or hardcoded links in a module,
template, node or menu which point to standard Drupal URLs it will bypass the
alias set by Pathauto."
In a nutshell what's happening is pathauto is creating a rewrite for ?q=node/<nid> only. This seems to make sense considering pathauto's goal in life is to create SEO-friendly URL's and considering most folks probably don't want the node edit urls indexed anyway, aliasing these as well would add unnecessary clutter.
So to answer your question it appears that you would need to either write a custom module to create aliases for these additional paths or hack up a copy of pathauto.
Changing the Menu Path on the Edit Page
I think that you might be able to do this by creating a new module and building a new alias each time you edit a node using hook_nodeapi.
@Allen: Do you think this could work?
I'm really couldn't say
nodeapi is one of the core hooks I haven't needed for anything yet so I haven't had a chance to look at it closely. Assuming it does work though you're creating three or more rewrite rules for every node in the database, any number of which are pointing to utility pages you wouldn't want indexed anyway. It'd probably make for a cool coding exercise but I would probably avoid doing anything like this on a production site unless there was a defined need.
One way to create edit aliasses
<?php
/<em>
</em> Implementation of hook_nodeapi
*/
function example_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
// Set path alias, for editing alias
// Function will prvent dupicates
// Downside: function will be triggered each time node is viewed
path_set_alias("node/".$node->nid .'/edit', $node->path ."/edit");
break;
}
}
?>