tags:

views:

11

answers:

1

I would like to be able to refer to a System Configuration value set in the Zotonic admin interface within a template.

In particular I would like to create a configurable password complexity regex so I can write a validate statement like the following:

{% validate id="new_password" type={format pattern=config.mod_admin_identity.password_regex %}

How do you refer to Config values from the admin interface in Zotonic validators?

A: 

The answer is quick to retrieve thanks to Arjan's new search I went from http://zotonic.com/search?q=config to http://zotonic.com/documentation/719/m-config and quickly devised a solution using m_config.

Here is a modification to _action_dialog_set_username_password.tpl that provides password complexity enforcement based on an admin config for module mod_admin_identity with key password_regex that auto-degrades to a simple presence check:

{% if m.config.mod_admin_identity.password_regex.value %}
    {% validate id="new_password" type={presence} type={format pattern=m.config.mod_admin_identity.password_regex.value} %}
{% else %}
    {% validate id="new_password" type={presence} %}
{% endif %}
Alain O'Dea