In the attached file you find a patch for creating URL aliases for the personal contatc form of each user. The default URL for this is "users/[user]/contact".

Comments

greggles’s picture

Status: Active » Needs work

Thanks for providing this. I actually think that the default pattern should be left blank.

The reason is that having too many aliases will slow down a site so for these potentially "low value" aliases I'd rather not provide a default. I think I'm going to do the same for the tracker and blog aliases.

Triskelion’s picture

Version: 5.x-2.0-beta3 » 5.x-2.2
FileSize
3.43 KB

I required links to user contact forms on a site where user profiles are NOT accessible to the public. I had to find a way to provide links to the contact forms which bypassed the user account pages.

This patch was exactly what I needed! It required a little work to get it to match the current version of pathauto, so I have attached a modified patch for 5.x-2.2.

greggles’s picture

Version: 5.x-2.2 » 6.x-1.x-dev

@triskelion - thanks for providing this patch! We're currently in feature freeze for 5.x-2 and 6.x-1.x. So, I'm moving this to 6.x-1.x-dev with the ultimate intention of applying it to 6.x-2.x-dev. We should probably do this first so that it applies somewhat cleanly before we do all the crazy changes.

Thanks again for your help!

greggles’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review

Here's a re-roll for 6.x-2.x-dev.

In light testing this worked great. I went back on my feeling about defaulting it to blank. Making it blank just felt like it would be hard for people to figure out what shold be inside of it...

greggles’s picture

patch...

As I said earlier, I feel like this should go in soon before the code drifts so far it has to be re-rolled for a 3rd time.

Also, @triskelion - to give a bit of a review so your patches can get committed faster in the future: I found some code style issues (using coder module) like $variable.'stuff' which should be $variable .'stuff' (at least for 6.x it is that way...) and some tabs instead of spaces and some trailing whitespace.

Freso’s picture

Status: Needs review » Needs work

Okay, since I've been appointed... eh. Something with being nit picky, here's my picked nit:
The "@@ -88,6 +88,31 @@ function tracker_pathauto($op) {" hunk contains a double newline.
Another one would be that the "Bulk generation of contact pages completed" messages could easily be enclosed in single quotes. But this is not as minor as the first comment, so this'll just be my secondary nit. :)
Also, $settings['placeholders'][t('['. $pattern .']')] = t($description); is bad. Don't ever do t($variable)! :x What is t('['. $pattern .']') supposed to return - and is this even something we want to have translated? I'm also not sure what $description is supposed to be, but there's got to be a better way.

(Also, I'd love if these were language aware, but I guess that's an issue on its own...)

greggles’s picture

Status: Needs work » Needs review
FileSize
3.75 KB

Ok, with your fixes this seems pretty good to me. I believe those errors were just copied and pasted from an older version of Pathauto and have since been changed. I tried to compare the two new functions to similar ones in that file but obviously am not as "nit" conscious as you are ;) Thanks!

Freso’s picture

Haha. My goal is to become the next Morbus. :P

But this new patch doesn't have any code that jumps out as being bad. I haven't tested though, so not marking RTBC. Just commenting that the code doesn't look malformed... :)

Morbus Iff’s picture

WHO SUMMONS ME?!

* if ($alias = pathauto_create_alias('contact', 'bulkupdate', $placeholders, $src, $user->uid)) { looks weird to me, especially since $alias is never used thereafter in the function. If pathauto_create_alias() returns an $alias (as opposed to, say, NULL or FALSE), then you don't need to assign to a variable you never use.

greggles’s picture

Status: Needs review » Fixed

Thanks for the review, Morbus. I committed this anyway and have created #274382: bulk generate assigns a variable and never uses it - stop that since the problem you identified is broader than this issue.

Thanks thesaint02 and triskelion for your help on this!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.