I'm using Pathauto to set my user profile pages to simply www.mysite.com/user_name

It works wonderfully.

However, I've created my first CCK/Views/Contemplate node, and now the $name function isn't working right.

I've explained everything here, but was directed to this forum.

The short version is that when creating a contemplate template using the $name call, it returns the user's name (right), but a link to $name ALSO simply returns the user's name. So if my user has a one-word name, great--it's going to the right place. But if they have a name with spaces, the spaces appear in the URL, which is different than the [name] call in Pathauto.

What am I doing wrong?

Thanks!

Comments

sinker’s picture

Wow, I just re-read my post and realized that it doesn't make much sense unless you click on the link to the original question. The person who helped me and directed me here said it best:

"Haven't used the pathauto mod myself, but you should be able to find out how to code your links with whatever variable pathauto spits out for $name (the pathauto=ized name variable, as it were)"

So yeah, that's what I'm looking for.

greggles’s picture

Status: Active » Closed (fixed)

I think what you want is "pathauto_cleanstring()".

I would suggest that you change your pattern to be users/[name] though due to the dangerous patterns problem.

I closed this because I think I've answered your question, but if that doesn't work please move this back to active status and let me know how/why it's not working.

sinker’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

I think what you want is "pathauto_cleanstring()".

Can you give me that in more context? How/when do I call this?

Thanks!

greggles’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I responded in that forum thread and wanted to document it here as well:

listened to by <b> <?php l($name,pathauto_cleanstring($name)) ?></b>

I think that's more or less what you'll want. The benefit of the l function is that it will handle clean urls or not automatically and can also provide the fully qualified domain name and path to the page even if you move your site to a new host. Neat, huh? It saves tons of manual work.

Let me know if you need more help.

sinker’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Plugging that in doesn't seem to be working--it leaves the name blank, so the text reads "listened to by on" with no name, link to profile, or anything.

greggles’s picture

Well, that's the function to use. I can't really debug your use of it from here so I'm afraid you'll just have to debug yourself.

One other tip - if you are linking to something like user/UID then you can just use the l() function like l('user profile','user/'. $uid) and it will automatically convert it to the internal alias for that path. Does that help?

http://api.drupal.org/api/5/function/l

greggles’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing given no response.