Forum Moderators: open

Message Too Old, No Replies

Auto linking text in asp

Building a link list

         

bateman_ap

10:07 am on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a thought, wondered if anyone could tell me if it is possible. Imagine we have a asp page that is built by pulling data from our sql database and writing it to the page, ie the body copy that would be pulled from the database might be "this is a great place to buy blue widgets and at a very low cost"

Is there a way to throughout the site to have a list of "linking words" that would see that "blue widgets" is in the copy and automatically make that into a link to www.bluewidgets.com?

ziggystardust

11:10 am on Apr 9, 2003 (gmt 0)

10+ Year Member



Sure, add a "dictionary-table", with common expressions and links.

Ie.
blue widgets - www.bluewidgets.com
red widgets - www.redwidgets.com

build the sqlquery, then just loop trough these words... and replace.

Do Until results.EOF
replace(bodycopy, results(0), "<a href=http://" & results(1) & ">" & results(0) & "</a>")
results.MoveNext
Loop

bateman_ap

12:11 pm on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, so i get this right, I create a new table with 3 values, (id, link text and url)

Then at the moment I would be using
Response.Write (Rs2.Fields("fld_widget_text").value)

But I presume I need to do something like
bodycopy = (Rs2.Fields("fld_widget_text").value)

Then run

Do Until results.EOF
replace(bodycopy, results(0), "<a href=http://" & results(1) & ">" & results(0) & "</a>")
results.MoveNext
Loop

But where would this go in the code?

bateman_ap

3:40 pm on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, was being silly, forgot to create the sql statement! Thanks for the help, works a treat!

ziggystardust

5:21 pm on Apr 9, 2003 (gmt 0)

10+ Year Member



You're welcome. I'm happy to hear it worked.