Fire custom concrete5 events

Submitted by remo - 3 years ago

In this trick,, we've shown you how to catch core events. While you can already do a lot of core events, you can even add your own events to let packages interact which each other. The code below fires an event called on_my_data_change which you can intercept in a package or site customization.

// fire event with name on_my_data_change
$data = array('id' => 1, 'slug' => '/foo');
Events::fire('on_my_data_change', $data);

// in your package, add the following code to the on_start method like shown
// here
Events::extend('on_my_data_change', function($data) {
    // handle $data..
Stats Categories Tags
comments powered by Disqus