Drupal paths/aliases

Jump 2 paragraphs for question

I tried to post on the Drupal forums, but I kept getting some spamming nonsense warnings, so after trying to wait the timer out a couple of times I gave up. I'm sure there's several Drupal g33ks here!

I've developed for a few years, mostly custom applications, but also Joomla as that's what was used at my first job. I'm looking into converting over to Drupal for my part time work, for the amount of customization and overall quality it gives. Now I am doing my first Drupal project for myself, a blog that hopefully won't take too much time to finish.

I use pathauto for normal aliases, which works really well. However I want the comment add,edit,permalink etc. URL's to be in a special way as well (content-title/comment/edit/12). After some thinking I created a module that used the pathauto module to create additional aliases for the comment links, however this leads to immense amounts of aliases even after a short period of time. So I found another way that wouldn't need any aliases through the database itself.

I found two related hooks:

  • hook_url_outbound_alter

  • hook_url_inbound_alter

I created a module that alters the comment URL's before they are output on the webpage, then when the URL is accessed it converts it back to it's original state.

I'm not too worried about the hook_url_inbound_alter since it will pretty much only run once per inbound URL, however hook_url_outbound_alter can run many times during a 'page creation', as I'm quite new to Drupal I want to make sure I don't do something stupid, and have as optimized code as possible. The positive thing is that the regex to match the comment URL's should run pretty fast, and the rest of the code is only run for those that match. But there may still be something that is not preferable, pages might in the future hold hundreds of comments, leading to the code to run multiple times for each comment.

I haven't made anything changable in the admin yet, since it's for my own project thus far, if I find it very useful I might add some options later and put it up as a downloadable module. If you have any tips, or anything I am very grateful! The tests I've done seems to be working just fine.

Code can be found here: http://pastebin.com/0CYAsV1J (couldn't get code formatting to work here on the forum)