m_site
Retrieve information that is stored in the site configuration. If you want to query values from the config table instead, you should use m_config.
Fetch a site configuration key
Example, fetching the site configuration key “hostname”:
{{ m.site.hostname }}
Fetching all configurations
It is easy to loop over all site configurations:
{% for key, value in m.site %}
{{ key }} -- {{ value }} <br>
{% endfor %}
Overriding config values
Zotonic has two places where a site’s configuration is kept. One is in the site’s config files, the other in the config table. The config table (accessible through m_config) overrules any module settings from the config file, for rows where the module key of the config value is set to site.
Within the site configuration, you can override module-specific configuration: Module configurations are defined with a property key equal to the module name, with a property list as value. For example:
{mod_foo, [ {hostname, "localhost"} ]}
will put the default “hostname” setting of the imaginary mod_foo
module to localhost
.
Default config values
Sites have the following default config settings:
Property | Description | Example value |
---|---|---|
environment | Set the DTAP status of the site. Can be one of production, development, test, acceptance, education or backup. Default: production | development |
hostname | The hostname of the site | example.com |
title | The title of the site. | “My Awesome Blog” |
protocol | The main protocol of the site. Used to construct urls. Default “http”. | “https” |
document_domain | The document domain used for cross domain iframe javascripts. Default is the same as the cookie_domain. | www.example.com |
cookie_domain | The domain to use on cookies. This defaults to undefined, which will equal the domain of the current request. | .example.com |
session_expire_inactive | User inactivity timeout after seeing that the user has not been active. Default: 14400 (4 hours) | 3600 (1 hour) |
autologon_expire | Auto logon cookie timeout setting. Default: 15552000 (3 months) | 31536000 (365 days) |
site | The name of the site, an atom. | wwwzotonic. |
hsts | Indicate if the site should use Strict Transport Security. When set, the browser will no longer use insecure http to access the site. Warning: Be sure your site is accessible via https before enabeling this feature. Default: false | true |
hsts_maxage | The time, in seconds which browsers are allowed to remember the HSTS setting of the site. Default: 17280000 (200 days) | |
hsts_include_subdomains | When set, the browser also does not use http for subdomains. Default: false | |
hsts_preload | When set, the site’s HSTS setting will be stored by the browser vender. This means that browsers only use https. Use with care, because it is hard to revert wrong settings. Default: false |