Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Reply
 
LinkBack Thread Tools
Old August 13th, 2008, 08:24 PM   #1
New Member
 

Join Date: Aug 2008
Location: Atlanta
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 englishclassics is on a distinguished road
Replace space with hyphen in URL

Hi, I need to replace the spaces in my URL's with hyphens, eg.
George%20III%20Mahogany%20Dining%20Table/23736.asp
becomes George-III-Mahogany-Dining-Table/23736.asp

Here is the bit of code that I am using to generate the URL's:

<a href="/furniture/antique/<% = prodname %>/<% = prodidnum %>.asp"><% = prodname %></a>

Those are SQL database values. Basically, I need some way to make prodname (George III Mahogany Dining Table) into George-III-Mahogany-Dining-Table just for the URL. I wonder if there is a way for me to add hyphens to prodname when adding items to the database and then name the result prodname2 and then just call that for the URL? I have no idea how to do that though.

I am using classic APS, IIS 5.0, Windows Server 2000 and ISAPI_Rewrite. I am on a dedicated server but my SQL database is in a shared environment.
englishclassics is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 14th, 2008, 12:31 AM   #2
New Member
 

Join Date: Aug 2008
Location: Atlanta
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 englishclassics is on a distinguished road
Re: Replace space with hyphen in URL

I got some help and it's fixed! Following is the code that did the trick:

Code:
<a href="/furniture/antique/<% = (replace(prodname, " ", "-"))%>/<% = prodidnum %>.asp"><% = prodname %></a>
englishclassics is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 7th, 2009, 08:26 PM   #3
New Member
 

Join Date: Feb 2009
Location: Brasil
Age: 28
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 heber is on a distinguished road
Re: Replace space with hyphen in URL


Code:
'-----------------------------------------------------
'Funcao:    FormataStringToUrl(ByVal Texto)
'Sinopse:    Substitui os caracteres para formar uma 
'	     string que possa ser utilizada na URL
'Parametro: Texto: Texto a ser transformado
'Retorno: String
'Autor: Heber ALmeida - www.heberonline.com.br 
'-----------------------------------------------------
Function FormataStringToUrl(ByVal Texto)
	FormataStringToUrl = Replace(Replace(LCase(Texto), "  ", " "), "\'", "")
	FormataStringToUrl = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(FormataStringToUrl, " ", "-"), "á", "a"), "é", "e"), "í", "i"), "ó", "o"), "ú", "u"), "ã", "a"), "â", "a"), "à", "a"), "ê", "e"), "ô", "o"), "ç", "c"), "/", ""), "'", ""), """", ""), "[", ""), "]", ""), "&", "-"), "#", ""), "+", ""), "{", ""), "}", ""), "ù", "u"), "ò", "o"), ".", ""), "?", ""), "!", ""), ":", ""), "´", ""), "`", ""), "õ", "o"), "\", "")
	FormataStringToUrl = Replace(Replace(Replace(FormataStringToUrl, "û", "u"), "¢", "c"), "¡", "i")
	FormataStringToUrl = Replace(Replace(Replace(FormataStringToUrl, "£", "e"), "¤", ""), "¥", "y")
	FormataStringToUrl = Replace(Replace(Replace(FormataStringToUrl, "¦", ""), "ª", "a"), "æ", "ae")
	FormataStringToUrl = Replace(Replace(Replace(Replace(FormataStringToUrl, "ë", "e"), "ì", "ì"), "ð", "o"), "Ä", "a")
	FormataStringToUrl = Replace(Replace(Replace(Replace(FormataStringToUrl, "ñ", "n"), "ø", "o"), "ý", "y"), "  ", " ")
	FormataStringToUrl = Replace(Replace(Replace(Replace(FormataStringToUrl, "þ", "p"), "€", "e"), "ÿ", "y"), "²", "z")
	FormataStringToUrl = Replace(FormataStringToUrl, "%", "")
	FormataStringToUrl = Replace(FormataStringToUrl, "---", "-")
End Function
heber is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
url hyphen space


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to replace the div content onclick? siva1117 JavaScript 1 August 10th, 2008 12:08 PM
Search and dynamic replace Aso PHP 9 June 20th, 2008 12:42 PM
JS replace help immi1979 JavaScript 15 December 7th, 2007 02:49 AM
Replace <iframe> for PHP delusion PHP 2 June 20th, 2007 10:51 AM
Using RQ Search and Replace for HTML tag editing diakin Forums, Blogging and Content Management 0 February 10th, 2007 05:13 AM


Search Engine Optimization by vBSEO 3.2.0 RC8