-
Notifications
You must be signed in to change notification settings - Fork 36
DevGuide PluginBasic ConfigDirective
Now that you have successfully registered your first plugin, let's see if we can't have it actually do something mildly useful.
We will begin by introducing you to a simple capability of plugins: the ability to define new configuration directives that can be placed within your system's config.cgi
file.
The behavior of most plugins is very dynamic in nature, meaning that their behavior changes depending upon their context, configuration, or a number of other different variables. One of the most common ways to change a plugin's behavior is through a configuration directive.
Configuration directives reside in your Melody config.cgi
file and provide system administrators with a way of customizing your plugin's behavior in a prescribed way without having to edit code.
In this first example we will define a configuration directive that will hold the URL to an image that we will want to later display on a web page. Here is a sample config.yaml
that registers this directive:
name: Good for Nothing Plugin for Melody
id: Good4Nothing
author_link: http://www.yourwebsite.com/
author_name: Your Name Here
description: This plugin is an example plugin for Melody.
version: 1.0
config_settings:
MyImageURL:
default: http://www.openmelody.org/images/overview-1.jpg
Look at that: you just added to the capabilities of your plugin without writing any code. Again.
The example above also shows how you can register a default value for the directive, just in case an administrator had not explicitly set a value.
Yet again, however, this configuration directive is not that helpful on its own. What we need is a way to access this configuration directive and display its contents on a blog or website. The following section will help with just this.
Questions, comments, can't find something? Let us know at our community outpost on Get Satisfaction.
- Author: Byrne Reese
- Edited by: