Jump to content


Help: Automatically removing special characters from urls


2 replies to this topic

#1 Nocturne

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 18 December 2007 - 10:58 PM

Hi all,

I'm trying to get some nice clean urls for my website. Right now they include () , & , " and so on and some letters are uppercase....

Is there any way to automatically remove all the special characters and convert the url to lowercase?

This is the code which output my urls:

<a href="{$item.id}/{$item.title|replace:" ":"-"|escape:"htmlall"}" class="sitelink">{$item.title|truncate:30:"...":true|replace:"_":" "}</a>

Thanks in advance & merry christmas :)

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 19 December 2007 - 12:09 AM

What language are you working with?! That almost looks like something is ran through a template class, but it is nothing i recognize.

If you're in php, i'd say use strtolower() and then replace everything but the accepted characters (which preg_replace() could do easily).

If you are actually using a template class, then which one is it? Short of knowing that, i would recommend asking whom ever made it for support on how to use it.

#3 Nocturne

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 19 December 2007 - 12:20 AM

View Postrc69, on Dec 19 2007, 12:09 AM, said:

What language are you working with?! That almost looks like something is ran through a template class, but it is nothing i recognize.

If you're in php, i'd say use strtolower() and then replace everything but the accepted characters (which preg_replace() could do easily).

If you are actually using a template class, then which one is it? Short of knowing that, i would recommend asking whom ever made it for support on how to use it.

Hi, thanks for your quick answer. I think the template class is "Smarty" and yes it is a php script.

Should I write it as this?

preg_replace:" ":"-","&":"-"

Sorry for being such a noob, but I really appreciate the help...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users