Whats the BEST way to page results from cfsearch?
I think my readers are being a bit pushy lately on “best” - I’m feeling the pressure. ;) Luckily this one is easy. The cfsearch tag allows for both a startrow and maxRows value. So to paginate, you would simply pass in startrow and set maxRows to startrow plus some arbitrary number for the number of results per page.
The only tricky bit is getting the total number of matches found. If you use the status attribute, like below:
<cfsearch collection="cfdocs" criteria="cf" name="results" startrow="5" maxrows="5" status="s">
You get a structure back that contains three keys: found, searched, and time. Found represents the total number of matches. You would want to use that for your paging.
p.s. Let me abuse my blog entry here and mention I added similar functionality to Seeker last night.