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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfsearch sort 1

Status
Not open for further replies.

BKP1

Programmer
Jan 19, 2007
8
US
How can I sort the results from cfsearch by date modified and/or by file name or title? I get the date modified field to display along with the file by using cfdirectory tag inside the loop.
I have the following code to index and search and display results:
<cfindex
action="refresh" collection="#collectionName#"
key="#uploadPath#"
type="path"
urlpath="#URLpath#"
extensions=".pdf,.doc,.txt"
recurse="yes">

<cfsearch name="GetResults"
collection="#collectionName#"
criteria="<WILDCARD>*#LCase(FORM.keywords)#*"
ContextHighlightBegin="<b>"
ContextHighlightEnd="</b>"
ContextPassages="1"
ContextBytes="500">

Display Results:
<cfset SESSION.searchResults = GetResults>
<cfoutput query="SESSION.searchResults" maxrows="#URL.maxRows#" startrow="#URL.startRow#">
<cfset FileName=GetFileFromPath(Key)>
<cfdirectory action="list" directory="#uploadPath#" name="getdatemodified" filter="#FileName#">

<a href="#url#" target="_blank">#filename#</a><cfdump var="#getdatemodified.dateLastModified#">-
<small>#Context#&nbsp;</small>
</cfoutput>
 
You'll have to find a way to aggregate the filename/date-modified value pair into a sortable object such as a list or a query. Use QueryAddColumn and QuerySetCell to append the DateLastModified to the searchResults recordset, and then use Query of Query to order the recordset by the modified date.

Look at QuerySetCell in the documentation for a good example.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Thnak you very much for your help. I got it to work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top