Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help...

Status
Not open for further replies.

webmigit

Programmer
Joined
Aug 3, 2001
Messages
2,027
Location
US
I need to wrap links that go too long so they don't force my page wider...

I've got linkfinder from CFComet.com (code below).. I want to be able to change where it says <A...>/1</A> to basically:

<A...><CFIF len(/1) GT 60>#left(/1,50)#<BR>
#right(/1,len(/1) - 50)#<CFELSE>/1</CFIF></A>

Thanks,
Tony Hicks

-----------------
<!---
===================================================================
Utility: ColdFusion LinkFinder v1.1
Author: Dain Anderson
Email: webmaster@cfcomet.com
Revised: June 10, 2001
Download: ===================================================================
Description:

This tag is an off-shoot of the CF_ColoredCode tag.
This utility will turn URLs within messages into active URLs and
will make email addresses active mailto links as well. The newest
addition also parses UNC paths as well as the file:/// protocol,
among many (many!) RegEx enhancements to the HREF and MAILTO
parse routines.
===================================================================
Usage:
<CF_LinkFinder DATA=&quot;#data_to_parse#&quot;>
OR
<CF_LinkFinder DATA=&quot;#data_to_parse#&quot; NAME=&quot;Return_variable&quot;>
===================================================================
Parameter(s):
(Required) DATA = &quot;Data sent to be parsed.&quot;
(Optional) NAME = &quot;Named variable to return.&quot;
===================================================================
Use anyway you want, but keep the above header in place.
===================================================================
--->
<CFPARAM NAME=&quot;Attributes.Data&quot; DEFAULT=&quot;&quot;>
<CFIF NOT LEN(Attributes.Data)><B><FONT COLOR=&quot;FF0000&quot;>Error: No data to parse!</FONT></B><BR></CFIF>
<CFSCRIPT>
this = Attributes.Data;
this = REReplaceNoCase(this, &quot;(((file:///)|([a-z]:\\)|(\\\\[[:alpha:]]))+(\.?[[:alnum:]\/=^@*|:~`+$%?_##& -])+)&quot;, &quot;<A TARGET=&quot;&quot;_blank&quot;&quot; HREF=&quot;&quot;\1&quot;&quot;>\1</A>&quot;, &quot;ALL&quot;);
this = REReplaceNoCase(this, &quot;([[:alnum:]]*://[[:alnum:]\@-]*(\.[[:alnum:]][[:alnum:]-]*[[:alnum:]]\.)?[[:alnum:]]{2,}(\.?[[:alnum:]\/=^@*|:~`+$%?_##&-])+)&quot;, &quot;<A TARGET=&quot;&quot;_blank&quot;&quot; HREF=&quot;&quot;\1&quot;&quot;>\1</A>&quot;, &quot;ALL&quot;);
this = REReplaceNoCase(this, &quot;(([[:alnum:]][[:alnum:]_.-]*)?[[:alnum:]]@[[:alnum:]][[:alnum:].-]*\.[[:alpha:]]{2,})&quot;, &quot;<A HREF=&quot;&quot;mailto:\1&quot;&quot;>\1</A>&quot;, &quot;ALL&quot;);
</CFSCRIPT>
<CFIF IsDefined(&quot;Attributes.Name&quot;)>
<CFSET &quot;Caller.#Attributes.Name#&quot; = This>
<CFELSE>
<CFOUTPUT>#ParagraphFormat(This)#</CFOUTPUT>
</CFIF>
-----------------
 
<cfoutput>
<table>
<tr>
<td>
<!--- originalString IS your return_variable --->
<cfset originalString = &quot;sajdfhsahfjsdhf&quot;>
<cfset tempArray = LISTTOARRAY(REPLACE(REPLACE(originalString,CHR(34),CHR(39),&quot;ALL&quot;),&quot;</a>&quot;,&quot;&quot;),&quot;>&quot;)>
#tempArray[1]#>
<cfset tempString = tempArray[2] >
<cfloop condition=&quot;LEN(tempString) GT 10&quot;>
#LEFT(tempString,10)#
<cfset tempString = RIGHT(tempString,LEN(tempString)-10)>
<br>
</cfloop>
#tempString#
</a>
</td>
</tr>
</table>
</cfoutput>

Hope this helps
 
Sorry.
To Test This
on line 6 change
<cfset originalString = &quot;sajdfhsahfjsdhf&quot;>
to
<cfset originalString = &quot;<a href='aboutblank'>sajdfhsahfjsdhf</a>&quot;>

The code firstly gets rid of &quot;s and replaces them with 's
Then splits the link up by >
the first index will be the opening tag missing its
ending '>'
Then the code cuts the text up by chunks of 10 and
inserts a <br>.
 
Unfortunately.. it didn't work quite right.. but it got me closer when I was before.. if you have a pop box, log in to (don't check Get Headers Only).. click a message.. and you'll see the message text three times..

The first is cf_linkfinder's processing of it.. the second is your code's processing of the unprocessed #body#.. and the third is your code's processing of the cf_linkfinder's processing of #body#..

Any suggestions?

Tony Hicks
 
Status
Not open for further replies.

Similar threads

  • Locked
  • Question Question
Replies
5
Views
483
  • Locked
  • Question Question
Replies
4
Views
413

Part and Inventory Search

Sponsor

Back
Top