Gossamer Forum
Home : Products : DBMan : Discussions :

AutoURL acting up

Quote Reply
AutoURL acting up
Hello, all!

I'm pleased to be the first to post a forum question on here. :)

I have a bit of an issue with the AutoURL code:

Code:
foreach $column (@db_cols) {
$test = ''; # clears the temp variable for each field
$test = $rec{$column}; # Assigns the field info to a temp variable
$test =~ s/<LI>/ /g;
$test =~ s/<([^>]|\n)*>//g; # Strip HTML codes out of the string
$test =~ m/([\w]+:\/\/[\w-?&;#~=\.\/]+[\w])/; # Finds the HTML line
$test = $1; # Assigns the temp variable to the matched HTML line

$rec{$column} =~ s/([\w]+:\/\/[\w-?&;#~=\.\/]+[\w])/<A HREF=\"$test\" target=\"new\">$1<\/A>/g;
$rec{$column} =~ s/(mailto:[\w-?@&;#~=\.\/]+[\w])/<A HREF=\"$1\" target=\"new\">$1<\/A>/gi;
}

Multiple URLs in my fields are rare, but not unheard-of. The first HTML link is perfect, going to the proper address. However, every address after that within the same field goes to the SAME address as the first rather than its own. I have tried a miriad of variations of this code to try to get around this shortcoming, but I'm at a total loss! Any ideas?

--Lee

Quote Reply
Re: AutoURL acting up In reply to
How are mulitple URLs within a field delineated? A space between? A comma?

Quote Reply
Re: AutoURL acting up In reply to
Well, looking through the forums available now I'm thinking this one isn't the right one. <G> But I'm not really sure... *shrug* Oh well.

Anyway, the deal is this. The autourl code takes URLs out of a bunch of text. It recognizes the inherant :// of any web address and considers it a URL. It grabs the entire word and... well you get the idea. :)

My problem is that if I have two web addresses in the same field, they both link to the same place. Like so:

Code:
yada yada visit my web site at <A HREF="http://addressone.com">addressone.com</A> and be sure to also visit this other useless website at <A href="http://addressone.com">someotheraddress.com</A>
Notice how they're both going too addressone.com? It's really annoying. ;)

And if you're wondering why I don't just use $1 for the URL as well as the URL text, it's because I had to work out a way to strip out the HTML code from the web addresses, in case a search term happened to be in the address. (primarilly to remove search term bolding.)

Any ideas? (should i move this to a different place?)

--Lee


Quote Reply
Re: AutoURL acting up In reply to
Don't worry about moving the thread or starting one elsewhere. We'll get it all ironed out.

The thing you need to do is to figure out how many URLs are in the field and do a loop. Somehow. Smile I'm really not sure how count the URLs. I had an idea, but it didn't work.


JPD