Authoring Plugins: Configuration best practice?

If my plugin requires configuration parameters, what is the best /
accepted / recommended way of achieving this transparently?



One option is to state in your usage instructions that some keys need to declared in your config (for example, “myplugin_u” and “mypluging_p”)

Then in your plugin’s init, you can do something like

<cfset variables.myplugin_u = arguments.controller.getSetting(“myplugin_u”)>
<cfset variables.mypluging_p = arguments.controller.getSetting(“mypluging_p”)>

You could even do something like ask the controller if a certain setting exists and, if it doesn’t, throw an error. That way, the plugin only works if all its configuration values exist.

  • Gabriel

Gabriel is quite right, that’s how I handle settings in my plugins.

I do the same as Dorioo.

Jason Durham

Thanks guys. That's what I have been doing, just wondered if there was
something specific in the framework that I was missing that might be
more elegant.

I'll crack on with that method.

Thanks again.