PRO: Basic JSON-/Twig-Usage with “_context” or “_parent”


If your JSON starts with “[{” try this (or see here if you add some more twig code):


_context<br> {{}}<br> 
_context : {{_context | json_encode }}<br>
{% for item in _context %}
item {{loop.inxes}}: {{item | json_encode}}<br>
{% endfor %}
_parent<br> {{}}<br> 
{% for item in _parent %}
_parent : {{_parent | json_encode }}<br>
item {{loop.inxes}}: {{item | json_encode}}<br>
{% endfor %}


[jsoncontentimporterpro nameoftemplate="contextparent"]

twig defines some Global Variables

  • _self: references the current template name;
  • _context: references the current context;
  • _charset: references the current charset.

_parent is almost the same as _context but:
note the difference of _context and _parent loops

In Action:

curlGET failed, http-code: 301