The Linux Page

Creating the right forum paths with autopath...

Today I finally found out how to fix the path of the forums.

The name of the vocabulary is "Forums". To access it as expected in pathauto, you use [vocab-raw].

The result of [vocab-raw] is "forums" (all lowercase.)

Then, by default, pathauto adds the list of categories to the path. This is done using the [catpath-raw]. Say you have a forum named "Linux Stuff", [catpath-raw] will return "Linux Stuff" as is. This makes sense because paths on Linux are case sensitive (actually, it's the same thing with Apache wherever you are using it, although it's a bit of a mess in that regard on MS-Windows and Mac OS/X.)

So... that is a problem because when I try to have the same path in my forum posts, it doesn't come out the same way at all. Actually, it comes out as "linux-stuff" which is what I'd expect.

The fact is that you can change the [catpath-raw] with [cat-raw]. Any token that includes the special keyword "path" is handled in a special way: it's not handled! (i.e. the value is left alone because it is expected to represent a valid path by itself.)

The thing is that the [catpath-raw] feature is not available for the node path, only [term-raw] is. So that's a mismatch between the forum structure and the actual posts in the forum.

Remember that if you have a path such as:

forums/linux-stuff/great-post-man

Then Google will check this folder:

forums/linux-stuff

because it is supposed to exist.

Unfortunately, if it is called:

forums/Linux Stuff

instead, it won't work too well.

So, now you know, if the name of a token includes one or more of the following "keywords", then it will not be lowercased and dashed as usual:

path alias url url-brief followed by -raw

   preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)

Note that I thought I tried without the -raw, but for sure the [cat] is more what I need because that's a one to one match to the [term] tag.