In our project, we have a component that allows us to easily add options to our database form our plugins (a bit like WordPress does it).
For this, we need to run a small piece of code in the plugin to tell the component a new setting is there:
$this->loadComponent('Kikioboeru/Kikioboeru.Settings'); // Create a new settings group $this->Settings->registerGroup('contact','Contact Settings'); // Add all settings for this plugin to the settings component $this->Settings->registerOption('text','smtp[host]','','contact');
I’ve added this to the
AppController of the plugin, but this gives a small issue since this code is never ran until we actually do something with the plugin itself.
This is a bit of an issue since it doesn’t use the plugin itself, the plugin basically just tells to the main app: “hey, I’m here, and these are the settings I want you to show the user (so he/she can change it without having to code)”.
Where should I add this code in the plugin (not in the main app) so that it will run when the plugin it loaded?