thoughts on auto pathing

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
chrisschaub's picture

I've lately been working on a few sites with 10K plus path aliases, all generated from pathauto. Mostly on dedicated boxes so resources aren't too much of an issue. It got me thinking about an alternate approach, maybe an addition to pathauto or a separate module. Ok, here goes ...

Pathauto has a nice way of defining path naming rules for content types. These paths are stored in the database as aliases. Good. But how about NOT storing any of these paths in the database. Just "hook" into Drupal to generate a path on the fly based on the pathauto ruleset.

Upon saving or updating any node, the pathauto "rules" would be checked to make sure there is not already content that "owns" that path based on its title. If there is already a piece of content that will generate that path based on its title, then redisplay the edit form and show a message -- "A node or category has already reserved this title, please choose another unique title."

So, it's a strict check to make sure all titles are unique on the site. If all node titles/categories can have unique titles then you can (maybe?) do this sort of thing with paths on the fly. Some sites will not want this type of restriction on unique titles, but in many cases it's good to not have duplicate H1 titles across a site.

So, just throwing this out for discussion. I'm not sure if there are hooks that could be used for this sort of thing -- need to do more digging. I fear the path lookup is deep in the Drupal core and not accessible. Don't want to use javascript like urlify since it won't work for search engines. Appreciate any comments or suggestions.

Comments

how does it work in the other direction?

Jo Wouters's picture

Maybe I'm missing something,
but how would drupal know that "/articles/thougs_on_auto_pathin" belongs to "/node/4020" ? There is no ruleset to define the conversion in that direction (from title -> node number).

mostly agree

greggles's picture

I mostly agree with Jo on this. If you just store the ruleset then when a request comes in it would have to basically generate the entire url_alias table on the fly and then find the right node to serve. That's probably not great for performance.

There is work to store the aliases with the nodes themselves which would improve performance for page construction and possibly slow it for incoming page requests: http://drupal.org/node/63635 That needs quite a bit of work if we want to use it. One problem with it in my mind is that we alias nodes, users, and taxonomy terms. Those all have data structures that would conveniently allow us to add on an alias column which stores the alias. We also can alias arbitrary pages (e.g. user/uid/tracker or aliasing meinsite to mysite) which do not have an immediately logical destination in our data model.

For speeding up the lookups one solution is this patch: http://drupal.org/node/100301 it needs to be re-rolled after the localization patches. There is also this whitelist/blacklist system: http://drupal.org/node/106559 which would help as well.

So, lots of room for real concrete improvements to go in during the Drupal6 finalization over the next month. There are clear ways to help out in most of those issues, so I encourage anyone interested to try to assist.

Regards,
Greg

--
Knaddisons Denver Life | mmm Free Range Burritos

Paths

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: