In this lesson, we extend the Craft CMS control panel using template hooks and events to display the prominently display current environment.
When I’m working in Craft CMS, I tend to have a lot of open tabs, and sometimes tabs from different environments of the same project. For that reason, it’s nice to be able to clearly see which environment I’m currently in, so I don’t test or update the incorrect environment.
To solve this, we’ll build a custom module that displays the environment in the title tag/tab name, and as a banner at the top of the control panel. Along the way, we will also learn about how to customize the control panel with template hooks and events.
You might remember that in a previous video, we talked about how to add custom template hooks in Craft CMS to make it simpler to inject custom code into your front-end templates.
Craft CMS also has template hooks for injecting your own code into the control panel templates.
However, things have changed over the last couple of major versions of Craft CMS, and the emphasis is now on using events instead of template hooks for customizing Craft CMS control panel.
Let’s take a look at this for some background information before we jump into how to customize the control panel with our own code.
Even though there aren’t that many CP hooks left to use, we’ll use one to manipulate the title tag and then move to Events in Craft CMS to add additional changes to the Control Panel.