Step 2: Using the Data

Once you’ve fetched data from the datasource, you’ll want to use it.
The basic considerations here are:

  • What data does the datasource provide?
    If it is valid JSON, we can continue.
    But what if we got invalid JSON, XML or CSV?
    The free version of the plugin only works with valid JSON!
    The PRO Plugin can repair some invalid JSON and can convert XML and CSV to valid JSON.
    JSON Example:
{ "aaaa": 
     "bbbb": "valbbbb",
     "cccc": "valcccc"
  • How is the JSON structured?
    You should be familiar with the basic structures of JSON files: objects, arrays, etc. – or become familiar by using the JCI-Plugins.
  • Using JSON with templates:
    The JCI Plugin formats JSON data with a template.
    The template must know what to do with the JSON to display the output.
  • The free JCI Plugin is pretty straightforward, adding JSON + template:
    it loops through the JSON and checks what commands the template gives. Those commands are the JCI parser commands. The result is HTML content for the website.
    Shortcode example with free JCI-Plugin:
[jsoncontentimporter url= basenode=aaaa]
{bbbb} and {cccc}
  • The PRO Plugin is the same as the free plugin but much more powerful:
    • It uses the twig parser, which is way more powerful than the JCI parser.
    • You have full control in the template for sending other datasource requests, manipulating data, and you have access to the page properties like logged-in users etc.
      Shortcode example with PRO JCI-Plugin:
[[jsoncontentimporterpro url= debugmode=10 parser=twig]
{{aaaa.bbbb}} and {{aaaa.cccc}}

The better way to do have a JCI-Template: Add one and name it “NUMBER_OF_TEMPLATE” plus adding URL etc..
Then use this Shortcode:

[jsoncontentimporterpro nameoftemplate=NUMBER_OF_TEMPLATE]

Common errors:
avoid / remove any linefeeds in the No URL defined: Check the shortcode - one typical error: is there a blank after url= ? statements. Linefeeds can cause the a shortcode-parameter is not available and the plugin has not the needed information.
when using the template-manager use only [jsoncontentimporterpro url=… id=…] and do NOT add [/jsoncontentimporterpro]. If this is there the id=… is ignored.
quotation marks are a common trouble-source: The best way is not to use quotation marks (works as long there is no blank space in the parameter. Also: When copypasting code sometimes the “wrong” quotation marks are inserted and wordpress gets confused. Ok are single (‘) and double (“) quotation marks. Problematic are other like “, ”, „, “

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
On this page: