Topincs keeps all users on the same page. Everybody can easily access the latest information. Special components can be designed for a user group, so that only relevant information is in their focus. This works well very well, but since existing information might be changed, notifications become necessary. This is a rare requirement, but the feature is really handy when the need arises.
Topincs notifications are therefore disabled by default. When they are enabled the bell icon is visible in the header. You can achieve this by simply editing the user group and setting the respective field to yes. The icon shows the number of unread notifications and when clicked a panel listing all notifications becomes visible. When the notification is created with a link, it is rendered as a hyperlink, otherwise as text. Below the panel there is a button to mark all as read.
Hint: Notifications are no tool for human-to-human communication.
Notifications are tiny programmatically created messages from the system to individual users. They are created by a change and are directed to a computed recipients list. Only users actually affected by the change should be informed. This is what sets them apart from emails.
Hint: Note is much shorter than Notification, so we use that when coding.
To define a note template you need to first display all topic types in Admin menu > User interface. The subsequent form asks for a mandatory name, so that you can recognize the template, and an optional life time which defaults to 14 days. The individual notes based on the template will be deleted after this duration. They are deleted even if some recipients have not marked them as read. They are only relevant in their lifetime.
Once you have defined your note template, edit its source code to define how recipients and text are computed. The interface of the respective methods is specific to the template. It needs to be respected when you create a note, which we will explain shortly.
<?php
// 12345 is the system id of this note template.
class NoteTemplate12345 extends AbstractNoteTemplate {
// Who needs to be notified?
function compute_recipients($wish) {
// Santa
$this->to("Santa Claus", $wish->href());
// And the responsible elf, if there is one.
if ($wish->has_elf()) {
$this->to($wish->get_elf(), $wish->href());
}
}
// What is the message?
function compute_text($wish) {
return sprintf("Wish cancelled: %s", $wish);
}
}
Once your note template is defined and coded, you can create notes from anywhere in the system. In most cases it will be a POST service or a trigger, since it supposed to announce a change, that would otherwise go unnoticed.
This page cannot be displayed in your browser. Use Firefox, Opera, Safari, or Chrome instead.
Saving …