Go to page content


Use the zotonic notifier from your templates. [new 0.8-dev]

Zotonic's notifier system makes it possible to create modular components with pluggable interface. The notifier system is used by internal core zotonic components like the authentication mechanism, the logging system and more. This model makes it possible to user the power of the notifier mechanism inside your templates.

Here is an example. When rendered the templates sends the notification banner. The first reaction is used to render the template.

{{ m.notifier.first[`banner`] }}

Here is an example of the use of map to insert footer navigation items. This works as follows. When the template is rendered the zotonic notifier is called with the message {footer_navigation, [{current_location=Id}]}. Zotonic modules can listen to this message and return this information. This can be very handy if you have to create dynamic interfaces based on what modules are enabled.

{% for item in m.notifier.map[{footer_navigation current_location=id}] %}
    {% include "footer_item.tpl" item=item %}
{% endfor %}


PropertyDescriptionExample value
firstSend the message between the square brackets to the notifier system. The value of the first reaction is used. The order in which the modules are called is based on the priority of the modules. `clicked`, {item_clicked role=`important`}
mapSend the message between the brackets to the notifier message. All reactions are returned in a list. The order in which the modules are called is based on the priority of the module.{navigation loc=id}

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.