plugin interface

Technical discussion for developers and service providers

plugin interface

Postby lygie » 11:27am, Tue 24 Jul, 2007

Hallo,
in the phplist/admin directory I can find a plugin directory. Is there an existing plugin interface for adding own features and if, is it documented?
lygie
PL Nut
 
Posts: 19
Joined: 11:17am, Tue 24 Jul, 2007

Postby H2B2 » 11:41am, Tue 24 Jul, 2007

The distribution archive comes with this plugins directory included: /lists/admin/plugins

These are the relevant settings you'll have to look at in config.php:
Code: Select all
# you can create your own pages to slot into PHPlist and do certain things
# that are more specific to your situation (plugins)
# if you do this, you can specify the directory where your plugins are. It is
# useful to keep this outside the PHPlist system, so they are retained after
# upgrading
# there are some example plugins in the "plugins" directory inside the
# admin directory
# this directory needs to be absolute, or relative to the admin directory

define("PLUGIN_ROOTDIR","/home/me/phplistplugins");

# uncomment this one to see the examples in the system (and then comment the
# one above)
#define("PLUGIN_ROOTDIR","plugins");


As to documentation on plugin development, this could be improved/extended I think. Anyway, this might help you get started:
If you want to create plugins, the place to start is the defaultplugin, which will contain coder documentation on what each method in the class does and how it interacts with the core code.
Ref: http://docs.phplist.com/NewIn211
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby lygie » 11:19am, Wed 25 Jul, 2007

As to documentation on plugin development, this could be improved/extended I think. Anyway, this might help you get started:


thank you so far. I wil try to get used to the plugin development and also try to write down my experiences and then post it :-)
lygie
PL Nut
 
Posts: 19
Joined: 11:17am, Tue 24 Jul, 2007

Howto Build an own Plugin for Phplist:

Postby lygie » 10:49am, Mon 30 Jul, 2007

In the last Days I made a few trials in building and including my own Plugin for Phplist. Here are my experiences so far.

You can define a Directory for Plugins in the config.php. There are comments in the config file, explaining how to do this.

admin/pluginlib.php will search through all .php files in this directory and try to include Plugins.

You must be carfull when defining this directory. As soon as there is at least one .php file in your defined directory, it is neccessary, that this file or all the files all carry some essential Informations, or the main Programm of phplist will no longer return anything.

In all phpfiles in the Plugindirectory must have at least two informations.

1) You need a class with the same name as your php file. That class has to extend the class phplistPlugins. For example when you have a myplugin.php in you directory, you need the class myplugin extending phplistPlugin.
2) The defined class needs the variable $coderoot, that tells where the code for the Plugin is stored

To make the Plugin do anything, you also need a file main.php in your coderoot directory of the Plugin that will contain the plugincode itself.

As soon as you have defined a new plugin by storing the essential information in your php file in the plugindirectory, the backend of phplist will automatically show a link to the new plugin in the sidebar.

Following this link will execute the main.php in the coderoot Directory of this plugin.

All shown output of the new Plugin will be put in the Main Windows of your phplist plugin.

As so far I coold not figure out for which reason there additional Functions and variables are defined in the Example plugins that came with phplist. In all my trials, there where no influences of them.
For example the $name variable is stored in the $class array, but i can not see a point where is is shown or given back to any other part of phplist.

Here is some example code to explain my text above:

newplugin.php in plugin directory:
Code: Select all
class newplugin extends phplistPlugin {

   var $coderoot ="customplugins/newplugin/";

}

main.php in /customplugins/newplugin/";
Code: Select all
echo "hello world"
lygie
PL Nut
 
Posts: 19
Joined: 11:17am, Tue 24 Jul, 2007

Postby H2B2 » 6:52pm, Tue 31 Jul, 2007

That should be useful info to others. Thanks, and keep us updated on your findings.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

adding the function adminmenu()

Postby lygie » 3:06pm, Wed 01 Aug, 2007

Hallo,

meanwhile I have figured out how the stuff with the adminmenu() function in the original examples for plugins works. If there is a adminmenu() function in your plugins phpfile in your plugin Directory, the main index.php will use the output array of this function for some information.
When you use a function like this:

Code: Select all
function adminmenu() {
    return array(
      "test" => "shown Item"
   );
  }

On your main menu in the admin Page you will find the link "shown item" under "plugins" the link will execute the "test.php" in your coderoot directory.
If no array is given it will not return anything here. You don´t need this function if you want to execute your plugin manually or from the sidebar.
lygie
PL Nut
 
Posts: 19
Joined: 11:17am, Tue 24 Jul, 2007

Postby H2B2 » 6:24pm, Thu 02 Aug, 2007

Thanks! I added a link to this thread in the "documentation" pages more or less related to the subject:
http://docs.phplist.com/PhplistHacks
http://docs.phplist.com/NewIn211


If you feel like it, you could create a new documentation page on plugin development in the documentation wiki: http://docs.phplist.com/DevelopmentTemplate

You'll need to register first in the wiki: http://docs.phplist.com/UserSettings
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006


Return to Developers Space

Who is online

Users browsing this forum: No registered users and 0 guests