Step 9: Twig-template engine

Prior to Version 3.0.0 and in the free Version the JSON Content Importer-Plugin is based on the proprietary “JCI-parser” with some great features. This is good and still available.

But: In some cases this parser / template-engine had limits. Therefore now you can use the popular Twig-engine with this plugin.

The usage is as following:


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

twig-Extensions (3 to 6 from Version 3.4.0 on):

  • Extension 1: Sort JSON by “sortbyjsonfield”
  • Extension 2: By “dateformat” you can set timezone and language / locale of time- and date-output. See example here.
  • Extension 3: By “convert2html” you can convert JSON-data into HTML
  • Extension 4: “removespecialcharsinurl” is useful for building URLs by lower strings, replacing blanks into dashes, converting “ä” into “ae” etc.
  • Extension 5: “stringshorter(length, suffix)” cuts a string to length and puts a suffix (e.g. “…”) at the end. This is useful for creating a Teasertext out of a long text.
  • Extension 6: “formatnumber(decimals, dec_point, thousands_sep)” formats numerical JSON-data
  • Usage of twig for JSON starting with “[{“: See twig and it’s _context