In addition to providing a variety of events that developers can hook into, concrete5 also provides an events system at the page type level. We discussed page types in detail in the first chapter of this book, but now we can add a custom event to our page types. In this recipe, we will create a page type called blog_post
and hook into the
on_page_add
event for that page type.
Page types and how to work with them are described in much more detail in Chapter 1, Pages and Page Types. Make sure events are enabled in concrete5 and that your /config/site_events.php
file exists.
The steps for defining a page type event are as follows:
Register the event handler in
/config/site_events.php
:Events::extendPageType('blog_post', 'on_page_add');
First, create a new page type file in
/page_types
calledblog_post.php
.Next, create the controller file for the page type in
/controllers/page_types/blog_post.php
.Create the controller class, extending the core...