I have a similar problem on a Drupal 7 site, and am posting as much to share my solution as to "subscribe" and hear from others about the potential pitfalls or alternative solutions.
In my case, I have a number of panels that display "related" content to a node.
Let's say that it's an artist node, and that I have a few panels or variants representing the
- artist (url artist/[artist-nid])
- their albums (albums/[artist-nid])
- their band history (history/[artist-nid]).
For SEF urls, I want to alias those to something like
- artist-name-profile
- artist-name-albums
- artist-name-band-history
Because pathauto doesn't "see" the panels, and because the urls are of an unusual structure (no '/' ) I wrote a custom module to do url rewriting using hook_url_inbound_alter() and hook_url_outbound_alter().
For Drupal 6 you can use http://drupal.org/project/url_alter It's baked into Drupal 7.
So basically, I maintain a cck field on the artist node containing a url friendly version of the artist name. Then use code something like the following.
function myModule_url_outbound_alter(&$path, &$options, $original_path) {
$parts = explode('/', strtolower($original_path));
$prefix = array_shift($parts);
switch($prefix) {
case 'albums':
if (!empty($parts[0]) && is_numeric($parts[1])) {
$url_fragment = myModule_get_unique_url_safe_artist_name($parts[1]);
$path = $url_fragment.'-albums';
}
break;
// etc
}
}
function myModule_url_inbound_alter(&$path, $original_path, $path_language) {
$parts = explode('-', strtolower($original_path));
$suffix = array_pop($parts);
switch ($suffix) {
case 'albums':
$map = implode('-', $parts);
$nid = myModule_get_nid_from_unique_url_safe_artist_name($map);
$path = 'albums/'.$nid;
break;
// etc
}
}
Pros,
- I get a great deal of flexibility on the url design - non-conventional urls are possible
- I do not need to have over 50,000 records in the url_alias table.
- I can quickly and easily change the urls without having to rebuild the alias table
- I can reach those pages pathauto can't
- It works.
Cons,
- every url passes through this test and the ones that match will be slowed down by at least one db query. (this doesn't appear to be much of a performance hit by YMMV)
- url changes require developer intervention
- For large numbers of panel variants, this function can become difficult to maintain, particularly because you have to be careful not to allow conflicts to arise. See below for example.
- This doesn't smell right as an approach
Conflicts can come up based on your url matching methodology. I the above case we split on '-', this can become a problem in this specific case if the artist url were simply artist-name and the artist's name was literally "Michael-albums" since this would be interpreted as an album page for "Michael" rather than an artist page for "Michael Albums".