diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index fdefbf16d..383bf4e65 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -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 diff --git a/docs/templates.txt b/docs/templates.txt index 4c138a884..19187a088 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -26,4 +26,38 @@ templates, you will need to apply these changes manually to your copies. + * 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: + + +
+
Loading..
+
+ +
diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 06bf673ee..044188676 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -3407,7 +3407,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'}) diff --git a/lib/WebGUI/Help/Asset_Thingy.pm b/lib/WebGUI/Help/Asset_Thingy.pm index 7bdd1be1b..25b131d38 100644 --- a/lib/WebGUI/Help/Asset_Thingy.pm +++ b/lib/WebGUI/Help/Asset_Thingy.pm @@ -236,6 +236,8 @@ our $HELP = { }, ] }, + { 'name' => 'searchResult_json', + }, ], related => [ { tag => 'edit thing template', diff --git a/lib/WebGUI/i18n/English/Asset_Thingy.pm b/lib/WebGUI/i18n/English/Asset_Thingy.pm index ddf210594..ccf77e1aa 100644 --- a/lib/WebGUI/i18n/English/Asset_Thingy.pm +++ b/lib/WebGUI/i18n/English/Asset_Thingy.pm @@ -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|,