Managing templates

Step 1 of the plugin is to get the JSON fro an URL /API. Step 2 is to use the retrieved JSON together with a template which has placeholders for the JSON-data.
The syntax of the template can be either the JCI-parser or the twig-parser (PRO-version only).

Also there are two ways to place the template:

  • Embed template at the shortcode on a wordpress-page / blogpost:
    [jsoncontentimporter(pro) debugmode=10 url=…]TEMPLATE-TEXT[/jsoncontentimporter(pro)]
  • The PRO-Version comes with a template-manager:
    Store the template and some attributes (like url) in one place and use it on different pages or posts.
    By using “id=NUMBER_OF_TEMPLATE” as Shortcode-parameter you can call this template from the manager.
    JCI PRO Version: Templatemanager

    JCI PRO Version: Templatemanager

Common traps:

  • Embedded template:
    WordPress is usually converting the embedded text. E.g. quotations marks are encoded to HTML-quotations marks. Then the template-engines (esp. twig) get an invlid source code and the wordpress displays an error. To check this you can add “debugmode=10” to the shortcode to see the twig-error. If so (esp. when formatting time dand dates in twig) you should put the template into the template-manager.
  • Shortcode tries to embed the template AND use the template manager:

    [jsoncontentimporterpro url=http://... id=NO parser=twig]
    {% for eventitem in event %}
    {% if eventitem.evs3|length > 0 %}
    {% endif %}
    {% endfor %}

    Here the plugin is ignoring the id=NO and is using the embedded template.