How to fetch a template file?

Permalink
I'm missing a way to fetch a template file, which is a view of a result row. The view should be transfered over json to the client and displayed after the page has already been generated.

It is of course possible to transfer only the data of the result object and compose the result row (view) with javascript, but it is a big overhead since the result row has a lot of placeholders and conditions - it is more easier to do the work on server side and tranfer the composed html.

Is there an approach to build partial templates and fetch to a variable without outputting them?

 
mesuva replied on at Permalink Reply
mesuva
Sure, there's nothing stopping you from using a page layout that outputs no header or footer, and then using a block template that outputs json (or xml or whatever) data instead of HTML with content.

I posted this in another thread today, it might give you an idea of how you can achieve this:http://www.mesuva.com.au/blog/technical-notes/adding-ajax-source-pa...
arodionov replied on at Permalink Reply
Thanks for advice, but I don't need to load the whole block content via AJAX. Actually I'm developing a tour search engine. The search process takes a lot of time, but I can retrieve results during the search process. So I need to show the results to user.

The result rows coming from server are placed with javascript on the right positions of the result list. So I only need to get the pieces of html over AJAX. This html pieces shold be prepared on server side, but they need to have a template file, which shold be in the themes directory.
jordanlev replied on at Permalink Reply
jordanlev
My general approach is to put the pieces of HTML templates into elements, then have both your page type view *and* a tools file (C5's name for Ajax responders) output those elements.