Step 8: JCI template engine

The JCI-template engine is default (alternative in PRO-Version: twig). A very basic example is here.

Some special add-ons for manipulating data from the JSON-feed:

Manipulate Output-Format (“street” is for any datafield-name):

  • “{street}”: Default-display of a datafield. If HTML is in the datafield-text, the HTML-tags are converted. E.g. “<” is converted to “&amp;lt;” etc.
  • “{street:html}”: If HTML is in the datafield any you want to display this as HTML the “:html” reconverts the html-converted text back to html.
  • “{street:htmlAndLinefeed2htmlLinefeed}”: Same as “{street:html}” plus “\n”-Linefeeds are converted to HTML-Linebreaks
  • “{street:purejsondata}”: In some cases the reconversion of the htmlalized datafield-text is not optimal. This is useful if the datafield-text HTML-Code is not fully htmlalized. E.g. Tags and specialchars (which should be HTML-Code, but are not) are in the datafield-text. “:purejsondata” gives access to the pure datafield-text without any manipulation.

Manipulate Output-Text:

  • PRO-Feature: “{street:ifNotEmptyDel:startleft,length}”
    Display from the datafield-text only the text from postion “startleft” on (conted from left to right) and the next “length”-chars right of it.
  • PRO-Feature: “{street:ifNotEmptyDelFromEnd:startright,length}”
  • Display from the datafield-text only the text from postion “startright” on (conted from right to left) and the next “length”-chars left of it.
    E.g. if one datafield-text is “image34856.jpg” and you want to replace “jpg” you can delete this by startright=0 and length=3 (counting from 0 at right to 3 for “jpg”).
    Thanks to Layth from Australia.
  • PRO-Feature:
    “{street:ifNotEmptyAddLeftRight:extratextleft##extratextright##}” and “{street:html,ifNotEmptyAddLeftRight:extratextleft##extratextright##}”
    Add additionals text left and right if datafield-text is not empty. E.g. is you want to display a link only if there’s an URL.
  • PRO-Feature:
    “{event:datetime,required_date_format,timezone_offset}”
    If the JSON-data contains time- or date-data: with this feature you can format the date/time as you like.
    required_date_format is the needed format, like “d.m.Y”, see here for options.
    timezone_offset must be numeric: If the input date is in text-date-format (e.g. “6.7.2015”) then timezone_offset is in hours. If the input date is an unixtimestamp, the timezone_offset is in seconds, hence you have to 3600 for each hour offset.  This number is added to the timestamp for setting the timezone if this should be other as in the JSON-data. If not required set to 0.
  • PRO-Feature: “{number:round,digits,up}”
    Only the first “digits” of “number” will be displayed. If “up” “1.5” etc. rounds to “2”. If “down” “1.5” gets “1”.
  • “{street:ifNotEmptyAddRight:extratext}”: If datafield “street” is not empty, add “extratext” right of datafield-value. allowed chars are: “a-zA-Z0-9,;_-:<>/ “
  • “{street:html,ifNotEmptyAddRight:extratext}”: you can combine “html” and “ifNotEmptyAdd…” like this
  • “{street:ifNotEmptyAdd:extratext}”: same as “ifNotEmptyAddRight”
  • “{street:ifNotEmptyAddLeft:extratext}”: If datafield “street” is not empty, add “extratext” left of datafield-value. allowed chars are: “a-zA-Z0-9,;_-:<>/ “
  • “{street:html,ifNotEmptyAddLeft:extratext}”: you can combine “html” and “ifNotEmptyAdd…” like this
  • “{street:urlencode}”: Insert the php-urlencoded value of the datafield “locationname”. Needed when building URLs.
  • “{street:unique}”: only display the first instance of a datafield. E.g. needed when JSON delivers duplicate data.

more JCI-template engine syntax: