ColdFusion Wrapper for Perlfect Search

Daniel Naber <[email protected]> Wed, 28 May 2003 18:50:58 +0200
Newsgroups gmane.comp.web.perlfect-search
Message-ID <[email protected]>
Peter Fairhurst has written a cold fusion wrapper for Perlfect Search, 
similar to the PHP wrapper. I'm posting it here so people can use it (and 
later find it in the archives). Thanks Peter!

Regards
 Daniel

-- 
http://www.danielnaber.de
perlfect_wrapper.cfm (text/plain, 2.6 KB)
<!---
	
			= = = = = = = = = = = = = = = = = = = = = =
			=                                         =
			=         Perlfect Search Simple          =
			=           ColdFusion Wrapper            =
			=                                         =
			=            by Pete Fairhurst            =
			=        ([email protected])         =
			=                                         =
			= = = = = = = = = = = = = = = = = = = = = =
	
	PLEASE NOTE:
	This wrapper is offered 'as is' - you use it at your own risk.
	Responsibility for its use rests entirely with the persons who
	choose to use it.
	
	GENERAL:
	This simple wrapper is based on the PHP one released by
	Daniel Naber.  It would be better facilitated by parsing the
	results using ColdFusion, so that the output can be customised
	dynamically.  You could achieve this by altering the way in
	which 'search.pl' creates its results sets (in HTML), and then
	passing that information into a ColdFusion array, ready for
	output.
	
--->

<cfparam name="searchString" default="">

<cfif isDefined("url.q") and url.q is not "">
	<cfset searchString = Trim(url.q)>
</cfif>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1;">
		<cfif searchString is not ""><title>Search results for '<cfoutput>#searchString#</cfoutput>'</title><cfelse><title>Search</title></cfif>
	</head>
	
	<body>
		
		<!--- This form must target the page where it appears (itself effectively) --->
		<form name="perlfect_search" method="get" action="perlfect_wrapper.cfm">
			<!--- Usual Perlfect inputs --->
			<input type="Hidden" name="p" value="1">
			<input type="Hidden" name="lang" value="en">
			<input type="Hidden" name="mode" value="all">
			<cfoutput><input type="Text" name="q" value="#searchString#"></cfoutput>
			<input type="Submit" value="Search">
		</form>
		
		<!--- Check for submission of non-empty query/term --->
		<cfif searchString is not "">
			
			<!--- Target the Perlfect Search script in your local CGI directory --->
			<cfhttp name="search_url" url="http://#cgi.http_host#/cgi-bin/search/search.pl" method="post" timeout="10">
				<!--- Pass the variables to the script --->
				<cfhttpparam name="p" type="FORMFIELD" value="#url.p#">
				<cfhttpparam name="lang" type="FORMFIELD" value="#url.lang#">
				<cfhttpparam name="mode" type="FORMFIELD" value="#url.mode#">
				<cfhttpparam name="q" type="FORMFIELD" value="#url.q#">
			</cfhttp>
			
			<!--- Display the content returned from the Perlfect HTML file --->
			<cfoutput>#cfhttp.fileContent#</cfoutput>
			
		</cfif>
		
	</body>
	
</html>