Information
This page documents useful functions that can be used in a service controller action after the execution of modifications (insert/update/delete)
Events
Trigger events to be displayed in notification streams
Learn more
Learn more more about events and activities
Copy to clipboard
TikiLib::events()->trigger('tiki.category.update', [ 'type' => 'category', 'object' => $id, 'user' => $user, ]);
Logs
Trigger log entries to be created
Forward
Forward to another service controller action
Copy to clipboard
return array( 'FORWARD' => array( 'controller' => 'tracker', 'action' => 'update_item_status', 'status' => 'DONE', 'redirect' => $input->redirect->text(), ) );
Redirect
Trigger a redirect to another screen, optionally with a message that will appear on the target screen in a remarksbox
Related libs and services
Copy to clipboard
lib/tikiaccesslib.php
Copy to clipboard
lib/core/Services/Broker.php
Redirect to a URL
Copy to clipboard
$accessLib = TikiLib::lib('access'); $accessLib->redirect('tiki-admin.php?page=wiki');
Redirect with a message to a URL variable
Copy to clipboard
$accessLib = TikiLib::lib('access'); $accessLib->redirect($return_url, tr('Your comment was posted.'));
Index update/rebuild
Tigger incremental update or complete rebuild of the unified search index.
Sample code
Copy to clipboard
TikiLib::lib('unifiedsearch')->processUpdateQueue(); TikiLib::events()->trigger('tiki.process.redirect'); // wait for indexing to complete before loading of next request to ensure updated info shown
Feedback
Trigger instant feedback for the user about the success of the action
Copy to clipboard
In the tpl file add this to the <form> element: class="confirm-action" In the controller add this return array: return array( 'modal' => '1', 'FORWARD' => array( 'controller' => 'utilities', 'action' => 'modal_alert', 'ajaxtype' => 'feedback', 'ajaxheading' => tra('Success'), 'ajaxmsg' => tra('Changes saved'), 'ajaxdismissible' => 'n', 'ajaxtimer' => '3', ) );