Author |
Topic |
|
giambona
New Member
USA
84 Posts |
Posted - 16 June 2001 : 16:05:40
|
Does anyone know if it is possible if it is possible to automatically add links to a message? For instance, if a user writes a message that has the word "Amazon" in it, it will automatically be linked as "http://www.amazon.com".
I haven't installed the forums yet but plan on setting them up within the next couple of weeks.
Thanks!
Jason Giambona giambona@optonline.net |
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 16 June 2001 : 16:14:54
|
inc_functions.asp
add this in your function Smile(fString)
fString = replace(fString, "Amazon", "http://www.amazon.com")
Dayve |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 16 June 2001 : 16:17:35
|
actually, I would recommend doing something like this instead..
fString = replace(fString, "[Amazon]", "http://www.amazon.com")
that way if someone was not referring to Amazon.com it would not format it...just a thought.
Dayve |
|
|
gor
Retired Admin
Netherlands
5511 Posts |
Posted - 16 June 2001 : 16:48:27
|
quote:
actually, I would recommend doing something like this instead..
fString = replace(fString, "[Amazon]", "http://www.amazon.com")
that way if someone was not referring to Amazon.com it would not format it...just a thought.
and if someone actually typed in http://www.amazon.com/ using [Amazon] wouldn't break the link.
Pierre Join the Snitz WebRing |
|
|
giambona
New Member
USA
84 Posts |
Posted - 16 June 2001 : 23:05:58
|
Thanks, but what I wanted to do was just have it add a url to the text that already says amazon. Also, is the above code case sensitive?
Thanks again!
|
|
|
gor
Retired Admin
Netherlands
5511 Posts |
Posted - 17 June 2001 : 01:07:28
|
That depends, you can have it both ways: fString = replace(fString, "Amazon", "http://www.amazon.com") or fString = replace(fString, "Amazon", "http://www.amazon.com", 0) do a casesensitive replace and fString = replace(fString, "Amazon", "http://www.amazon.com", 1)
isn't case sensitive and would also replace aMaZOn
see: http://msdn.microsoft.com/scripting/ for quick and easy lookups of VBScript syntax
Pierre Join the Snitz WebRing |
|
|
giambona
New Member
USA
84 Posts |
Posted - 17 June 2001 : 17:10:52
|
Not to be a pain in the ass, but would it be possible to do this same thing but from a database? For example, I would have a table with a list of stores and when someone posts a message, it would automatically search the database for the store and insert the link. The reason I want to do this is because I want to insert referral links when someone types the store name.
Again, sorry for being such a pain. I know very little about programming in ASP.
Thanks!
Jason Giambona giambona@optonline.net
|
|
|
Deleted
deleted
4116 Posts |
Posted - 17 June 2001 : 17:35:10
|
quote:
Not to be a pain in the ass, but would it be possible to do this same thing but from a database? For example, I would have a table with a list of stores and when someone posts a message, it would automatically search the database for the store and insert the link. The reason I want to do this is because I want to insert referral links when someone types the store name.
Again, sorry for being such a pain. I know very little about programming in ASP.
Thanks!
Jason Giambona giambona@optonline.net
No pain at all... But it will not be a feasible solution, each time a user posts, or edits his/her message, another database access will slow down things. Or you will keep these database contents in a dictionary object or array in server memory (maybe application object).
Try this (didn't try myself, put double quotes for each Q you see - I couldn't find another way to show this code here as it is):
fString = replace(fString, "[Amazon]", "[url=QQhttp://www.amazon.comQQ]Amazon[/url]")
This way you will have the word Amazon, as a link to http://www.amazon.com. Like here:
quote:
In Amazon I found a book called ... bla bla
I think a more major problem is replacing things without taking the context in the sentence into account. This will cause a lot of mis-replacements. Will you replace for "bestbuy" for example if someone types "best buy" ,one types "Amazon's support"...
But this is a MOD, which needs time to code. Let me try... These are the steps: 1. define a table, say "mylinks" with 2 fields: STR1 for a word to replace (string30), STR2 for the link to replace (string255) 2. Fill it with desired walues (don't ask me for an admin interface ). 3. at the same place defined earlier, run this:
strSQL = "SELECT * FROM mylinks" rs_links = my_Conn.execute (strSQL)
Do While not (rs_links.EOF or rs_links.BOF) fString = replace(fString, Q[Q & rs_links(0) & Q]Q, Q[url=QQQ & rs_links(1) & QQQ]Q & rs_links(0) & Q[/url]Q) rs_links.MoveNext loop
rs_links.Close set rs_links = nothing
Again replace each Q with double quotes ("). I hope it works .
Think Pink
Edited by - bozden on 17 June 2001 18:11:43 |
|
|
giambona
New Member
USA
84 Posts |
Posted - 19 June 2001 : 02:23:57
|
actually, what i was wanted to do was just have it get the url from the database only when the message is first posted so that the database isn't constantly accessed to get links.
thanks again for your patience
|
|
|
giambona
New Member
USA
84 Posts |
Posted - 21 June 2001 : 09:09:08
|
i guess there's no way to do this? |
|
|
Deleted
deleted
4116 Posts |
Posted - 21 June 2001 : 17:43:57
|
quote:
i guess there's no way to do this?
There is a way, but as I said before it needs carefull examination and test. Probably somebody else can show you, or you may wait until I have spare time to play with it.
If you can "read" ASP, have a look at post.asp and post_info.asp. The above idea may need to change a bit.
Sorry for now.
Think Pink |
|
|
giambona
New Member
USA
84 Posts |
Posted - 25 June 2001 : 01:30:54
|
all right, thanks anyway
|
|
|
|
Topic |
|