Plugin code is regular PHP code, and should be written as if editing the VisioList scripts directly.
When creating a plugin, you should bear in mind that your code will have access to all variables and classes that are exposed at the point where the hook is placed. You also need to ensure proper security measures are in place.
A few guidlines to follow when creating plugins.
1) all plugins must be put in the /plugins/ directory.
2) The name of the plugin folder should be in CamelCase (aka medial case)
-example: ThisIsCamelCase
3) each plugin should start with the following files:
info.php - A file outlining the name of the plugin, the author name/contact, support URL, and a line for database changes.
here is a typical plugin info.php file:
If your plugin makes changes to the database, you will need an install.php file. Here is a sample:
install.php
index.html - a blank file
now that you have the required files, its time to try running some code via a new plugin. For this example we'll add a simple line of text to our members stats pages.
if you open sources/details.php you will see the available hook locations:
this particular plugin comes after all of the stats are compiled, so from here our plugin has access to all variables defined before it. Notice the unique name of this hook location: details_compile_details.
We want to insert some code in this location, so we create a new file called details_compile_details.php and place it in our plugin/myplugin/ directory.
in this file we are going to add a "template variable" and a line of simple text, just to illustrate how this works:
great! now all we need to do is make it show up in the template. There are 2 options for this:
option 1) open stats.html template and add our new template tag {$myplugin_text}
OR
option 2) use the template hooks. To use this option we add an additional line to our details_compile_details.php file:
now our line of text will automatically be inserted into your stats pages, just before the stats tables. NO file edits required!
just to recap, here is how the file structure for our sample plugin might look:
/plugins/MyPlugin/info.php
/plugins/MyPlugin/index.html
/plugins/MyPlugin/stats_compile_stats.php
if you want to share this plugin, simple zip all of the files/folders into MyPlugin.zip. Now it can uploaded & installed through the admin panel.
Using Plugin Templates
one really nice feature of the VisioList plugin system is the plugin templates. Take the example above, instead of having our content/markup defined directly in the PHP we can create a new HTML template for it
so to use the template option we open our stats_compile_stats.php and use the following code instead of our original 2 lines:
Next, we create a new file called my_line_of_text.html and upload it to /plugins/MyPlugin/my_line_of_text.html
inside this new "template" my_line_of_text.html we can put our HTML markup and use our template tags as we would in any other template. for example:
this will work on any skin, each can have its own CSS definitions!
Posting your plugin in the forum
Your post must include the following for Version update notifications
VERSION 0.1#
The word version must be in UPPERCASE with a space before the number. Immediately following the number must be a # symbol.
In your post, give as clear of installation instructions as possible. Also describe what the plugin does, post screenshots where applicable.
well that was a quick and dirty look at how to create plugins, alter the database using plugin installer, bundle your plugin for distribution, use plugin templates, and use template hooks to make your plugin super easy to install.
Enjoy and happy coding!
When creating a plugin, you should bear in mind that your code will have access to all variables and classes that are exposed at the point where the hook is placed. You also need to ensure proper security measures are in place.
A few guidlines to follow when creating plugins.
1) all plugins must be put in the /plugins/ directory.
2) The name of the plugin folder should be in CamelCase (aka medial case)
-example: ThisIsCamelCase
3) each plugin should start with the following files:
info.php - A file outlining the name of the plugin, the author name/contact, support URL, and a line for database changes.
here is a typical plugin info.php file:
PHP:
<?php
//info.php
// You must give a name for your Plugin.
$pluginname = 'My Amazing Plugin';
$author = 'Me';
$email = 'me@mydomain.com';
//The url is where the user is to be sent for updates, this must be on the Visiolist Community
$url = 'http://www.visiolist.com/community/YOUR-THREAD-ID';
// The version # is used for update notifications
$version = '0.1';
//If ANY changes need to be made to the database set install to 1, else keep 1
$install = 0;
?>
install.php
PHP:
<?php
$DB->query("ALTER TABLE {$CONF['sql_prefix']}_settings ADD something VARCHAR( 255 ) NULL", __FILE__, __LINE__);
?>
now that you have the required files, its time to try running some code via a new plugin. For this example we'll add a simple line of text to our members stats pages.
if you open sources/details.php you will see the available hook locations:
PHP:
eval (PluginManager::getPluginManager ()->pluginHooks ('details_compile_details'));
We want to insert some code in this location, so we create a new file called details_compile_details.php and place it in our plugin/myplugin/ directory.
in this file we are going to add a "template variable" and a line of simple text, just to illustrate how this works:
Code:
$TMPL['myplugin_text'] = 'Hello World!';
option 1) open stats.html template and add our new template tag {$myplugin_text}
OR
option 2) use the template hooks. To use this option we add an additional line to our details_compile_details.php file:
Code:
$TMPL['myplugin_text'] = 'Hello World!';
$TMPL['stats_before_stats'] .= $TMPL['myplugin_text'];
just to recap, here is how the file structure for our sample plugin might look:
/plugins/MyPlugin/info.php
/plugins/MyPlugin/index.html
/plugins/MyPlugin/stats_compile_stats.php
if you want to share this plugin, simple zip all of the files/folders into MyPlugin.zip. Now it can uploaded & installed through the admin panel.
Using Plugin Templates
one really nice feature of the VisioList plugin system is the plugin templates. Take the example above, instead of having our content/markup defined directly in the PHP we can create a new HTML template for it
so to use the template option we open our stats_compile_stats.php and use the following code instead of our original 2 lines:
PHP:
$TMPL['myplugin_text'] = 'Hello World!';
$TMPL['stats_before_stats'] .= $this->do_plugin_skin('./plugins/MyPlugin','my_line_of_text');
inside this new "template" my_line_of_text.html we can put our HTML markup and use our template tags as we would in any other template. for example:
Code:
<div class="something">
<b>This is my plugin text:</b> {$myplugin_text}
</div>
Posting your plugin in the forum
Your post must include the following for Version update notifications
VERSION 0.1#
The word version must be in UPPERCASE with a space before the number. Immediately following the number must be a # symbol.
In your post, give as clear of installation instructions as possible. Also describe what the plugin does, post screenshots where applicable.
well that was a quick and dirty look at how to create plugins, alter the database using plugin installer, bundle your plugin for distribution, use plugin templates, and use template hooks to make your plugin super easy to install.
Enjoy and happy coding!
Last edited by a moderator: