Using Modx 2.8.4, I have a simple search form (employing Formit and FormitRetriever). After submitting the form, the user is redirected to a results page (which works fine) where I integrated a simple snippet into the page template like this:
[[!apicalls? &query=
[[!+fi.search]]]]
This is the code of my snippet which simply queries an HTTP API endpoint to gather JSON data:
<?php
$ch = curl_init('https://www.foo.com/?search='.$query);
curl_setopt(...);
$apiresult = curl_exec($ch);
curl_close($ch);
return "foostring";
What happens with this code is, that the content of $apiresult (= the entire JSON string) is instantly rendered into the page and I don’t know why since I am not returning it!? Before outputting, I’d like to perform further processing on the JSON data (like extracting certain fields etc.). Why does the snippet render the response into the page? How can that be avoided? You can easily tell that I just recently started developing my own snippets and still keep struggling with the very basics =(