App icon displayed in the main menu, which is usually created by means of the {$wa->apps()}
method, is capable of displaying a round red indicator with some brief information about events which require urgent attention of a user; e.g., the number of new orders in an online store or that of new comment in a blog. The picture below shows how such an indicator appears in the Webasyst backend:
In order to add such an indicator to your app’s icon, create file wa-apps/[app_id]/lib/config/[app_id]Config.class.php
with class [app_id]Config
extending system class waAppConfig
and implementing method onCount()
as shown below:
<?php class myappConfig extends waAppConfig { public function onCount() { ... return $value; } }
The value returned by method onCount()
will be displayed in the red indicator. When implementing the method, keep in mind that it is automatically executed once a minute. If you need to hide the indicator, then this method should return an empty value.
Changing app icon link URL
In addition to displaying an indicator, method onCount()
also allows changing the URL of the app icon link. For example, the icon of the Blog app points to the list of new comments (if set up accordingly); otherwise it opens the list of blog posts. You can dynamically change the URL of your app’s icon link in a similar fashion. To do so, ensure that method onCount()
returns an associative array with the following elements:
array( 'count' => $value, //indicator value 'url' => $url, //app icon link URL )
You can also use onCount()
method to execute some regular actions once a minute without displaying an indicator. In this case the method simply should not return any value.