Hi,
I just constructed a snippest that will highlight each word on the results page (very
much like MSDN
results page). SUPPORT MULTIPLE keywords!
I just did it in a couple of minutes and HAD TO GIVE IT TO YA to look and use.
I will post the optimized version soon...
*class="highlight" reffers to the design you want to highlight
in my case:
<style type="text/css">
..highlight{background-color : Yellow;}
</style>
This is the coldfusion code you'll need:
<cfset a=ArrayNew(1)>
<cfset a=ListToArray(q," ")> <!---q is the query form field--->
<cfoutput query="x"> <!--- match your query/verity switch here--->
<cfset thisrow="">
<cfif Arraylen(a) eq 1><cfset toary=1>
<cfset row=""><cfelse><cfset row="ReplaceNoCase("><cfset
toary=evaluate(Arraylen(a)-1)></cfif>
<cfloop index="i" from="1" to="#toary#">
<cfset row=row&"ReplaceNoCase(">
</cfloop>
<cfset row=row&"#chr(34)##SUMMARY##chr(34)#"> <!--- you can change SUMMARY to whatever
you're searching/displaying as results--->
<cfloop index="i" from="1" to="#Arraylen(a)#">
<cfset thisrow=thisrow&",#chr(34)##a[i]##chr(34)#,#chr(34)#<font
class=highlight>#a[i]#</font>#chr(34)#)">
</cfloop>
<cfset row=row&thisrow>
#evaluate(row)#
</cfoutput>
this will work on multiple words!
Send me your comments.
Thanks,
Michael Lugassy
Interactive Music Ltd.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists