Catch concrete5 events

Submitted by remo - 6 years ago

There are a number of events in concrete5 with which you can inject code into actions happening in the core of the CMS. You can find a list of the events on this page The example below shows you how to catch every page view action. You can use this to add a custom logging function, inject things into the page and more. The code has to be put in a file called "controller.php" in a directory called "event_test" in your "packages" folder. You'll also have to install that package before the code in on_start is actually executed. Update: As mentioned by Jeremy, the event will not be executed, if a page is loaded from the full page cache. If your site depends on events, make sure you've disabled the full page cache.

class EventTestPackage extends Package {

    protected $pkgHandle = 'event_test';
	protected $appVersionRequired = '5.6.2';
	protected $pkgVersion = '1.0';

	public function getPackageDescription() {
		return t('Event Test Package');

	public function getPackageName() {
		return t('Event Test');

	public function on_start() {
		Events::extend('on_page_view', function($page) {
			$currentPageId = $page->getCollectionID();
			// do whatever you like

Stats Categories Tags
comments powered by Disqus