Forum OpenACS Q&A: Search results page ignores template

Collapse
Posted by James Harris on
I've been working on creating a site with OpenACS 4.6.3 and I've noticed that while the search page uses the templating system, the search results page doesn't.

I haven't looked too deeply at this yet, but does anyone know if there is a simple reason for this behaviour?

By the way, congratulations to everyone working on the OpenACS project.  I haven't looked at it for a couple of months and the quality of the packages and documentation has very markedly improved.  Keep up the great work - I'll be trying to help out once I get my new site up and running.

Collapse
Posted by Tilmann Singer on
The reason is that retrieving the search results is potentially slow, so the results page returns the header chunk of the page immediately to the browser with ns_write to provide visual feedback to the user. Otherwise the user wouldn't see anything until all results are returned and rendered by the templating system.

I think there is an easy way around this though, which would both render the page with the appropriate template and still return the first part of it immediately. It would simply need to call adp_parse with a separator string in the place of the search results, split the return value of adp_parse by the separator string and return the chunks with ns_write (storing the footer until the results are finished). If I have time someday I'll try to make that change.

Collapse
Posted by Andrew Piskorski on
Yeah, that would be basically be the 'chunks' method of using template::adp_parse - unless somebody has since created a slightly nicer API for this sort of thing, that is.

It might be nice to be able to do ns_write style stuff within the templating system without having to take the performance hit of doing template::adp_parse all the time. (Normally, the Templating System compiles the parsed ADP to a Tcl proc, byte compiles that, and caches everything. I think you lose that by calling template::adp_parse explicitly.) But I never really thought about that.