Configuration with ZenConfig

Configuration files

Each site has configuration files: site.ini for site variables and theme.ini for theme variables.

These files are located in the directory: /data/sites/PROJECT/.

ZenConfig is a format for configuring configuration data.

Format specifications

Comments

comments start with a '#' at the start of the line:

# Comments start with a sharp symbol: '#'

Keys/Values

The key/value is the most basic element. A symbol :separates the name and value of each key. To the left of the sign :is the key (variable name). The key contains only letters and numbers and the underscore. Values ​​can be of type string, number, boolean, null, array, object.

# clé: valeur
name: "Namaskar" 
theme: "bootstrap5"
version: 2.3
ajax: false

# ceci est un objet
langue :  { label : "English", url : "en"}

# ceci est un tableau
fruits: ["pomme", "banane", "orange" ]

Sections

A section appears in square brackets ([]) on its own line. After defining a section, all keys will be linked to that section. Sections end at the very next section designation or at the end of the document; there is no specific “end of section” separator.

# nom de la section :
[site]
name: "Namaskar" 
theme: "bootstrap5"

[site.language]
default: "fr"
menu: [
    { label : "fr", url : ""},
    { label : "en", url : "en"}
]

[site.menu]

main: [
    { label : "Accueil", url : ""},
    { label : "Documentation", url : "documentation"},
    { label : "Téléchargement",  url : "download"}
]

The values ​​can be read from the templates in the following way:

{{ site.name }}
{{ site.language.default }}

If a variable does not exist, the returned value is null.

Example of reading variables from a template

# Namaskar.fr

[site]
name: "Namaskar" 
domain: "namaskar.fr" 
 
[site.menu]

main: [
    { label : "Accueil", url : ""},
    { label : "Documentation", url : "documentation"},
    { label : "Téléchargement",  url : "download"}
]
{{ site.name }}
{% for item in site.menu.main %}
<li class="nav-item">

  {% if item.active %}
  <span class="nav-link active" aria-current="page">{{ item.label }}
  </span>
  {% else %}
  <a href="{{ homepath }}/{{ item.url }}" class="nav-link">{{ item.label }}
  </a>
  {% end if %}
</li>
{% end for %}