Adding Your First Configuration Directives
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
Why Use Configuration Directives?
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 Movable Type
mt-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 Movable Type
author_name: Your Name Here
description: This plugin is an example plugin for Movable Type.
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 web site. The following section will help with just this.