By jim_at_miramontes on
I've created a module -- call it "foo" -- and am using pathauto to change the URLs for nodes of type foo like so:
http://example.com/node/123 -> http://example.com/foo/123
Trivial, all's well; it works fine. Meanwhile, since foo nodes are editable, people with editing ability see the "view" and "edit" tabs on pages showing a foo node. Editing works fine, but the link to the edit page is not /foo/123/edit, but /node/123/edit. I'd obviously like to see foo in the pathname; I'm also losing meaningful breadcrumbs on the edit page, which I suspect is a related matter.
So: Is there any way to use pathauto (or something else?) to make these related pages show up as, for instance, /foo/123/edit?
Comments
Several ways
You can try to us URL Aliases to replace "node/" with "foo/". Have not tried.
You could change "Default front page:" from "node" to "foo" in the /settings/site-information page.
Maybe you could suggest this as a feature request for pathauto.
The thing that might be the coolest is to have front page editing. Like this site makes. http://www.crosstec.de/realtime-content-editing.html Perhaps you could modify that to work for you.
In your module I would
In your module I would create a new alias everytime a node is created via the insert $op in nodeapi.
I would make the src 'node/$nid/edit' and make the dst 'foo/$nid/edit'.
That should take care of it :)
Yeah, that makes sense, in a
Yeah, that makes sense, in a pragmatic sort of way. Some experimentation shows that this doesn't do anything about the breadcrumbs not working on the foo/$nid/edit path, but I guess that's another matter... Thanks for the suggestion!
A related Drupal style question
Is it better to use nodeapi for this purpose than to put the same call into the foo_insert function? (A parallel question exists for calls to delete the "extra" aliases if the foo is deleted, of course.) It seems like either would work; is one preferred over the other for any particular reason?
If foo is a custom node type
If foo is a custom node type that is created via the your foo module then the preferred way would be to use the foo_insert, foo_update and foo_delete hooks. If the node type is not created in the module than nodeapi is the way to go.
Also as for the breadcrumbs... creating an alias should still use the system path for the edit page so if you are experiencing issues it probably has to do with something else and not the alias itself.
That's what I thought (and
That's what I thought (and had done); thanks.
url_alter & subpath_alias
Pathauto for Drupal 6.x can't do that yet. In the meantime something similar can be done with a combination of 2 modules: url_alter & subpath_alias. Read more at http://drupal.org/node/313411#comment-1801782
Maybe some code in there could be use for your module.