still another
      How can I highlight certain words in a string ?

        <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
       <title>test</title>
       <style>
        .highlight{background-color:yellow;}
       </style>
      </head>
      <body>
       <cfset oldstring = "this is a  test with words coldfusion and
searched words">
       <cfset searchedstring = "coldfusion">
       <cfset newstring
=rereplacenocase(oldstring,"(#searchedstring#)","<span
class=""highlight"">\1</span>","ALL")>
       <cfset highlightsearchterm
=rereplacenocase(oldstring,"(coldfusion)","<span
class=""highlight"">\1</span>","ALL")>

<cfoutput>#highlightsearchterm#</cfoutput><br><cfoutput>#newstring#</cfoutpu
t>
      </body>
      </html>



Dave
----- Original Message -----
From: "Tuan" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, February 14, 2003 6:18 PM
Subject: Re:RE: RE: Highlighting search keyword problem


> Does anybody else have any other suggestion or alternatives.  I've thought
about doing this before, but that would mean I would have to edit a lot of
templates for this highlighting function to work.
>
> ---------- "Raymond Camden" <[EMAIL PROTECTED]> writes:
>
> So basically your search returns matches as ids, and you link to
> article.cfm?id=X or some such? If so, in your link, simply pass along
> the search terms again. On your article.cfm, do (pseudo-code)...
>
> <cfset data = the content from the database>
> <cfif isDefined("url.searchTerms")>
> <cfset data = use replace to replace searchterms matches with
> <font color='red'>#searchterm...
> </cfif>
>
> <cfoutput>
> #data#
> </cfoutput>
>
>
> =======================================================================
> Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
> Member of Team Macromedia
>
> Email    : [EMAIL PROTECTED]
> Blog     : www.camdenfamily.com/morpheus/blog
> Yahoo IM : morpheus
>
> "My ally is the Force, and a powerful ally it is." - Yoda
>
> > -----Original Message-----
> > From: Tuan [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 14, 2003 4:01 PM
> > To: CF-Talk
> > Subject: Re:RE: Highlighting search keyword problem
> >
> >
> > Well, my document template is pulling the data from the
> > database but its not using the query thats run when the
> > search function is started.
> >
> > ---------- "Barney Boisvert" <[EMAIL PROTECTED]> writes:
> >
> > Are you saying that your document templates contain the
> > content directly, rather than pulling it from the database?
> > If that's the case, you're stuck, unless you somehow read
> > that template into a variable so you can manipulate it (with
> > replaceNoCase).
> >
> > > -----Original Message-----
> > > From: Tuan [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, February 14, 2003 1:32 PM
> > > To: CF-Talk
> > > Subject: Highlighting search keyword problem
> > >
> > >
> > > Ok, I've searched and read many topics on how to highlight keywords
> > > from a search result, but im still having problems figuring
> > this out.
> > > All of the topics and examples that i've seen shows how to do it if
> > > your search result(detailed) page is created by ur search query. If
> > > thats the case then you would use the ReplaceNoCase
> > function on your
> > > search query.  Or other examples showed that the text was
> > already set
> > > to a variable which then was used by the ReplaceNoCase function to
> > > highlight the text.
> > >
> > > But my problem is what if in your application you have a search
> > > function that runs and the search results shows a list of
> > doc titles
> > > that contains the keyword that the user searched.  Now each
> > doc title
> > > most likely has a different template name associated with it.  When
> > > you click on the title it will take you to different templates that
> > > existed previously w/o having any relationship with the
> > search query
> > > at all (except for it contained that keyword).  How can i apply the
> > > highlighting of the keywords to these already existing
> > documents?  I'm
> > > sorry if this isn't very clear.
> > >
> > >
> > >
> > >
> >
> >
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to