I've only done this with description and title tags on html pages. This
could get hairy with CF templates because of the need to parse all CF tags.
This is a simplistic version of what needs to be done.
<cffile action="read" file="file_name" variable="testvar">
<cfset findopentag="<body>">
<cfset findclosetag="</body>">
<cfset starttag=ReFindNoCase("#findopentag#",testvar)>
<cfset endtag=Find("#findclosetag#",testvar)>
<cfset numchars=endtag-starttag -Len(findclosetag)+1 >
<cfset bodycontent=Mid(testvar,starttag+Len(findopentag),numchars)>
You need a Regex expression to find a start tag for "<body>" to account for
its properties and things like "onload=whatever()" before finding the ">".It
also needs to parse out CF tags and conditional expressions. Then set this
string equal to "findstarttag". This snippet then creates the bodycontent
variable by starting at the end of the starttag (starttag+Len(findopentag))
and adding the number of characters(numchars) between that and the start of
the "endtag". Using a regex subExprs[] array that comes with Refind() is a
more elegant way to figure out the start and stop position but this example
illustrates the method.
To make sure that the text that you want to highlight or make bold is not
inside a CF or HTML tag like <img> or <style> etc. you would then need to
regex each occurence of the text(in your case the search term) and use the
back referencing capability to make sure the occurence is not inside a set
of "< >". This would mean that it lies outside of a tag.
I'm sorry that I am not able to give you the regex examples that you need
but that is not exactly my strong suit. My concern is that this might cause
quite a bit of overhead. Try to find a regex wiz if you are not one and have
it written and then plug it into a nice custom tag.
-----Original Message-----
From: sebastian palmigiani [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 22, 2001 6:48 AM
To: CF-Talk
Subject: Re: bold verity search terms
Thanks James.
There is one thing I am unclear though. How do you exclude certains areas of
the page in the parsing. For example, how do you limit the parsing to
whatever is in between the body tags? Also, if there is an image that has a
name that matches the search term then that image name will also get the
bold treatment.
Sebastian
on 2/21/01 11:21 PM, James McCullough at [EMAIL PROTECTED] wrote:
> Sebastian,
>
> On your output page Verity gives you access to the "Summary" variable and
> you could do a simple loop over the criteria and a simple replace.
>
> <cfparam name="form.criteria" default="funny Fusion">
> <cfparam name="Summary" default="James is the funny guy with Cold Fusion
> Experience">
> <cfloop list="#form.criteria#" index="num" delimiters=" ">
> <cfset summary=ReReplace(summary,"#num#","<b>#num#</b>", "ALL")>
> </cfloop>
> <cfoutput>#Summary#</cfoutput>
>
> You could then do a CFFILE for the HTML page and create a variable that
> comes from parsing the content between the body tags and
> do a similar type replace. I would loop over the search terms because the
> content match may be separated.
>
> You are on the right track. One thing that I have found is that parsing
the
> content of the page and inserting it into the database and using that when
> indexing gives me a workaround for the fact that Verity does not index
> titles and descriptions. Parse between the title tags and description tags
> and you can index them.
>
> -----Original Message-----
> From: sebastian palmigiani [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 21, 2001 5:07 PM
> To: CF-Talk
> Subject: bold verity search terms
>
>
>
> Any ideas on how you would make bold <b> the verity search term in an htm
or
> cfm file that is returned from <cfsearch>?
>
> The one way I can think of is to use <cffile> to get the html file and
then
> do a replace of the search term with <b>search term</b>.
>
> Am I on the right track?
>
> Sebastian
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists