Actually, this is a bit too simplified because what I needed was a way to
search for url's in a body of text without knowing what they are.  Here's
what I came up with...a little custom tag called CF_GetLinkList.  

If anyone can find holes in this, let me know...so far it seems to be
working fairly well...basically, it will take a body of text (html
obviously) and pull out all the URL's from that body of text.  I'm sure
there's something else out there (and maybe something a bit more
sophisticated) but this is working for me, for now. 

After using this tag to get the links, I then loop through the LinkList and
replace each one with my new link.

Here's the code for the tag in case anyone's interested (this assumes that
the first character at the end of an 'href' value will always be either a
space, a single quote, a double quote, or a greater than sign.  If I need to
check for any other possibility, please let me know.

<!--- cf_getlinksfromtext 

REQUIRED ATTRIBUTES:

TEXT = "body of text you wish to search for links"

OPTIONAL ATTRIBUTES:

VAR = "name of variable to store the link list" - defaults to:  LinkList

--->
<CFPARAM NAME="ATTRIBUTES.Var" DEFAULT="LinkList">
<CFSET EndListToCheck = chr(32) & chr(34) & chr(39) & chr(62) >
<CFSET NewText = ATTRIBUTES.TEXT >
<CFSET Hit = findnocase("href=",newtext) >
<CFSET temp = SetVariable("caller." & ATTRIBUTES.VAR,"") >
<CFLOOP CONDITION="Hit">
        <CFSET NewText = mid(newtext,Hit+5,len(newtext))>
        <CFIF left(newtext,1) EQ chr(34) OR left(newtext,1) EQ chr(39)>
                <CFSET newtext = mid(newtext,2,len(newtext)) >
        </CFIF>
        <CFSET EndHit = FindOneOf(EndListToCheck,NewText) >
        <CFIF EndHit>
                <CFIF NOT ListFindNoCase(Evaluate("Caller." &
attributes.Var),left(newtext,EndHit-1)) >
                        <CFSET temp = SetVariable("Caller." &
attributes.Var,ListAppend(Evaluate("Caller." &
ATTRIBUTES.VAR),left(newtext,EndHit-1))) >
                </CFIF>
                <CFSET NewText = mid(NewText,EndHit,len(NewText)) >
                <CFSET Hit = findnocase("href=",NewText) >
        <CFELSE>
                <CFBREAK>
        </CFIF>
</CFLOOP>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:199742
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to