To all the plugin developers out there, I would like to get some feedback on what I am currently planning on implementing for the Plugin Manager with regards to plugin configuration options.
So, to start with, here is some sample code that might appear in remote post:
my $blog_id = 1;
my $author_id = 1;
eval "use MT::Plugins::Config;";
if (!defined $@) {
require MT::Blog;
require MT::Author;
MT::Plugins::Config->add_variable ( Blog_ID => {
plugin => 'remote post',
var => \$blog_id,
desc => "Destination blog for all remote post pings",
allowed_values => { map { $_->name => $_->id } MT::Blog->load },
use_hash_values => 1,
});
MT::Plugins::Config->add_variable ( Author_ID => {
plugin => 'remote post',
var => \$author_id,
desc => 'Author as whom to post remote post pings',
allowed_values => { map { $_->name => $_->id } MT::Author->load },
use_hash_values => 1,
});
}
Basically, the idea is that this plugin can operate with or without the Plugin Manager installed. If it is not, the user just changes the values in the initial declaration. Otherwise, the Plugin Manager can handle the validation and storing of the values.
So, let me go into a little more detail about all the hash keys I plan to include:
plugin: Plugin namevar: Reference to the variable that should hold the configured value (if you don't understand exactly what a Perl reference is, think of it like a pointer).desc: Description of the variableallowed_values: Hash containing possible values for the variableuse_hash_values: If set to a true value (i.e. 1), the Plugin Manager will display the hash keys to the user for choosing, but will store/assign the hash value of that key. Otherwise, it will only use the hash keys.regexp: Whileallowed_valuesexplicitly sets the possible values,regexpgives you a little more flexibility. Just set it to a regular expression that the value of the variable must match (e.g.'\d{1,3}'for a 1-3 digit number).
In the future, I would like to expand this to include dynamic lists of values. To use remote post as an example, I would use it to define a list of remote post id's that a site administrator could use to designate different author-blog-category combinations.
Any thoughts? Concerns?
You might consider adding something that explains a bit more why this is of value to Plugin developers. How this fits into the Plugin manager as a whole and why a developer would want to add this extra code to their plugin.
Seems complicated. Maybe we could just do something like defining specific variables?
$VERSION = "0.10;
$AUTHOR = "Brandon";
Would that work?
Seems complicated. Maybe we could just do something like defining specific variables?
$VERSION = "0.10;
$AUTHOR = "Brandon";
Would that work?
Would this also let me develop and work on a plugin that is not in the plugin database yet?
And actually, more to the point, has this at all been added? I would love to be able to move data away from the config file (which if not configured right, could easily be accessable to the world, so its a bit of a security risk) and this would be an awsome method (with fallback to the file if nothing else works.)
My only issue is here its very limited as to the kind of data that would work. I'd want to be able to have some way of selecting a blog id, and associating data with that. But still with the ability to have multiple blogs setup with thier own set of information (does that actually make any sense?)
Hello.i'am from china!can i make friends with you?
i'am from china!can i make friends with you?