| 1 | # Configuration Assistant |
|---|
| 2 | # Author: Byrne Reese |
|---|
| 3 | # Copyright 2008 Six Apart, Ltd. |
|---|
| 4 | # License: Artistic, licensed under the same terms as Perl itself |
|---|
| 5 | |
|---|
| 6 | OVERVIEW |
|---|
| 7 | |
|---|
| 8 | This plugin is prototype for how to allow theme and plugin developers to easily |
|---|
| 9 | surface a form within Movable Type for configuring their theme/plugin and the |
|---|
| 10 | corresponding template tags that can be used within a template WITHOUT HAVING |
|---|
| 11 | TO USE PERL AT ALL! |
|---|
| 12 | |
|---|
| 13 | This plugin works by allowing a developer to use their plugin's configuration |
|---|
| 14 | file as a means for defining what the various settings and form elements they |
|---|
| 15 | would like to expose to a user. |
|---|
| 16 | |
|---|
| 17 | See the SAMPLE CONFIG YAML below for an idea of how this works. |
|---|
| 18 | |
|---|
| 19 | PREREQUISITES |
|---|
| 20 | |
|---|
| 21 | - Movable Type 4.1 or higher |
|---|
| 22 | |
|---|
| 23 | INSTALLATION |
|---|
| 24 | |
|---|
| 25 | 1. Unpack the ConfigAssistant archive. |
|---|
| 26 | 2. Copy the contents of ConfigAssistant/plugins into /path/to/mt/plugins/ |
|---|
| 27 | |
|---|
| 28 | REFERENCE |
|---|
| 29 | |
|---|
| 30 | The data structure for input form elements is relatively straight forward. |
|---|
| 31 | This plugin adds support for a new registry key called "plugin_config". |
|---|
| 32 | |
|---|
| 33 | The plugin_config element has a child element which corresponds the plugin's |
|---|
| 34 | id. It is this element under which all the various fields are defined under |
|---|
| 35 | "fieldsets". |
|---|
| 36 | |
|---|
| 37 | Each plugin can have multiple fieldsets, or grouping of input parameters. |
|---|
| 38 | Each fieldset should have a unique key or identifier. |
|---|
| 39 | |
|---|
| 40 | Under each fieldset is a sequence of fields. |
|---|
| 41 | |
|---|
| 42 | Each field supports the following properties: |
|---|
| 43 | |
|---|
| 44 | * type - the type of the field. Supported values are: text, textarea, select, |
|---|
| 45 | checkbox |
|---|
| 46 | * label - the label to display to the left of the input element |
|---|
| 47 | * hint - the hint text to display below the input element |
|---|
| 48 | * tag - the template tag that will access the value held by the corresponding |
|---|
| 49 | input element |
|---|
| 50 | * values - valid only for fields of type "select" - this contains a comma |
|---|
| 51 | delimitted list of values to present in the pull down menu |
|---|
| 52 | * rows - valid only for fields of type "textarea" - this corresponds to the |
|---|
| 53 | number of rows of text displayed for the text area input element |
|---|
| 54 | |
|---|
| 55 | In order to surface the form under your plugin's settings area, you will need |
|---|
| 56 | to define a blog configuration template like so: |
|---|
| 57 | |
|---|
| 58 | blog_config_template: '<mt:PluginConfigForm id="MyPluginID">' |
|---|
| 59 | |
|---|
| 60 | TEMPLATE TAGS |
|---|
| 61 | |
|---|
| 62 | Each plugin configuration field can define a template tag by which a designer |
|---|
| 63 | or developer can access its value. If a tag name terminates in a question mark |
|---|
| 64 | then the system will interpret the tag as a block element. Here are two example |
|---|
| 65 | configs: |
|---|
| 66 | |
|---|
| 67 | feedburner_id: |
|---|
| 68 | type: text |
|---|
| 69 | label: "Feedburner ID" |
|---|
| 70 | hint: "This is the name of your Feedburner feed." |
|---|
| 71 | tag: 'FeedburnerID' |
|---|
| 72 | use_feedburner: |
|---|
| 73 | type: checkbox |
|---|
| 74 | label: "Use Feedburner?" |
|---|
| 75 | tag: 'IfFeedburner?' |
|---|
| 76 | |
|---|
| 77 | And here are corresponding template tags that make use of these configuration |
|---|
| 78 | options: |
|---|
| 79 | |
|---|
| 80 | <mt:IfFeedburner> |
|---|
| 81 | My feedburner id is <mt:FeedburnerID>. |
|---|
| 82 | <mt:Else> |
|---|
| 83 | Feedburner is disabled! |
|---|
| 84 | </mt:IfFeedburner> |
|---|
| 85 | |
|---|
| 86 | SAMPLE CONFIG YAML |
|---|
| 87 | |
|---|
| 88 | blog_config_template: '<mt:PluginConfigForm id="MyPluginID">' |
|---|
| 89 | plugin_config: |
|---|
| 90 | MyPluginID: |
|---|
| 91 | fieldset_1: |
|---|
| 92 | label: "This is a label for my fieldset" |
|---|
| 93 | description: "This is some text to display below my fieldset label" |
|---|
| 94 | feedburner_id: |
|---|
| 95 | type: text |
|---|
| 96 | label: "Feedburner ID" |
|---|
| 97 | hint: "This is the name of your Feedburner feed." |
|---|
| 98 | tag: 'MyPluginFeedburnerID' |
|---|
| 99 | |
|---|
| 100 | SUPPORT |
|---|
| 101 | |
|---|
| 102 | http://forums.movabletype.org/codesixapartcom/project-support/ |
|---|
| 103 | |
|---|