Dav
Dav

Reputation: 150

str_replace a .TPL variable?

I have a variable named {$user.login} that I use in a URL like this:

http://profiles.mysite.com/{$user.login}

I want to replace spaces with + symbols like this:

"User name" becomes "User+name".

This way, my links will be cleaner.

Instead of http://profiles.mysite.com/User%20name I would have http://profiles.mysite.com/User+name

Any way I can do this? Thanks!

Upvotes: 0

Views: 525

Answers (1)

drew010
drew010

Reputation: 69967

The PHP function urlencode translates spaces into + signs.

Try: http://profiles.mysite.com/{$user.login|urlencode} in your template.

Upvotes: 2

Related Questions