Voog.com

Data

Represents custom data property of article, page or site. The values can be saved to corresponding objects using API and custom data Javascript toolkit.

For example page data under key "bgcolor" can be obtained from its object as follows:

{{ page.data.bgcolor }}

As data can be saved in a JSON structure, the corresponding child objects are also accessible from the template directly:

Saved JSON data:

{
  "bgcolor": "gold",
  "bg" : {
    "image": "myimage.jpg",
    "width": "100px",
    "height": "100px"
  },
  "fruits": ["apple", "orange", "lemon"]
}

In template:

BG color: {{ page.data.bgcolor }}<br>
BG Image: {{ page.data.bg.image }}<br>
// Rendering all keys and values in object
{% for item in page.data.bg %}
  Key is: "{{ item[0] }}" and value is "{{ item[1] }}" <br>
{% endfor %}
// Iterating arrays
{% for fruit in page.data.fruits %}
  {{ fruit }},
{% endfor %}

Example output:

BG color:  gold
BG Image:  myimage.jpg
Key is: "image" and value is "myimage.jpg"
Key is: "width " and value is "100px"
Key is: "height " and value is "100px"
apple, orange, lemon