Adds Thingy template variable to permit Javascript visualisation of search results

This commit is contained in:
Patrick Donelan 2010-09-21 15:04:09 -04:00 committed by Colin Kuskie
parent e63ce7881c
commit 329c396a3e
5 changed files with 47 additions and 0 deletions

View file

@ -16,6 +16,7 @@
- fixed #11876: packing templates, snippets, headtags removes conditional CSS comments
- fixed #11877: Criteria Builder on "shortcut by alternate criteria" gets ugly with many checkbox items
- fixed #11878: Addons title not internationalized
- added Thingy template variable to permit Javascript visualisation of search results (Patrick Donelan, SDH Consulting Group)
7.10.0
- fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters

View file

@ -36,4 +36,38 @@ templates, you will need to apply these changes manually to your copies.
</tmpl_unless>
<tmpl_loop story_loop>
* Thingy searchResults_json
This is a JSON-encoded version of searchResults_loop, which allows people to access Thingy search results
in Javascript/Flash/etc.. For example, you can use OpenFlashCharts2 (http://teethgrinder.co.uk/open-flash-chart-2)
and SWFObject to access the data and then display it as a pretty custom chart via the following:
<tmpl_if searchResult_loop>
<div id="chart-container">
<div id="chart">Loading..</div>
</div>
<script type="text/javascript">
function open_flash_chart_data() {
var data_json = "<tmpl_var searchResult_json ESCAPE=JS>";
var data = YAHOO.lang.JSON.parse(data_json);
var chart = {
elements: [
// populate dynamically from data object
]
};
return YAHOO.lang.JSON.stringify(chart);
}
// Embed the chart
swfobject.embedSWF(
'/path/to/open-flash-chart.swf', // url
'chart', // container element id
'100%', // width
'100%', // height
'9.0.0', // version
'/path/to/swfobject/expressInstall.swf', // expressInstall
{ loading: 'Loading...' }, // flashvars
{}, // params
{} // attributes
);
</script>
</tmpl_if>

View file

@ -3349,7 +3349,11 @@ sequenceNumber');
push(@searchResult_loop,\%templateVars);
}
$var->{searchResult_loop} = \@searchResult_loop;
# Also expose the search results in the template as a json-encoded string
# so that people can e.g. visualise the results via Javascript
$var->{searchResult_json} = JSON->new->encode(\@searchResult_loop);
$p->appendTemplateVars($var);
$var->{"form_start"} = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl,method=>'GET'})

View file

@ -236,6 +236,8 @@ our $HELP = {
},
]
},
{ 'name' => 'searchResult_json',
},
],
related => [
{ tag => 'edit thing template',

View file

@ -659,6 +659,12 @@ Simply replace "key1"/"value1" with your own name/value pairs},
context => q|Description of a tmpl_var for the template help.|,
},
'searchResult_json' => {
message => q|JSON-encoded version of searchResult_loop so that you can access the data in Javascript|,
lastUpdated => 1285094918,
context => q|Description of a tmpl_var for the template help.|,
},
'things_loop' => {
message => q|A loop containing the Things that are defined for this Thingy Asset, with links to management
functions for those Things|,