Chapter 2 - telling pluck more about your module

Now that you know where to store your data for your module, we can start telling pluck that your module exists, and give the CMS some more information about it.

We always need to tell pluck the following things about your module:

  • The "human-readable" name of your module
  • A short introduction to your module
  • The name of the directory where the module is stored
  • The path to the icon of your module
  • The version of the module
  • The name of the module author
  • The authors website
  • With which version(s) of pluck your module is compatible

We will save this information in the file data/modules/name_of_the_module/module_info.php.

About module_info.php

Let's assume we want to create a poll module. First thing we do, is create the directories data/modules/polls and data/settings/modules/polls, because these directories are only created automatically when a module is installed through the administration center. Since our module does not even exist yet, we need to create these directories ourselves.

Now we create the file data/modules/polls/module_info.php, where we will save the information about our newborn poll module. We'll walk through the needed variables one by one.

$module_name

First, we tell pluck the "human-readable" name of our module. This is the name that the users of pluck will see when using your module, and thus does not need to be the same as the name of the directory where the module is stored. Let's assume we want to call our module simple poll, then we put the following code in module_info.php:

$module_name = "simple poll";

$module_intro

This variable we use to give a short introduction of one or two sentences on the module. For example:

$module_intro = "create a poll for your visitors and let them vote";

$module_dir

We use $module_dir to tell pluck in which directory your module is installed. Pluck will also use the variable to get access to the user-settings directory, which thus needs to have the same name as the $module_dir variable. In our case (with the directories data/modules/polls and data/settings/modules/polls) we put the following code in module_info.php:

$module_dir = "polls";

$module_icon

$module_icon tells pluck where the icon for the module is stored. Each module needs to have a small icon, preferably saved in PNG format, 32x32 in size. The icon will be used in the administration center of pluck.

We can for example use the following code.

$module_icon = "images/icon.png";

The variable is relative to the module directory, so if we use the code listed above, pluck will search for the icon in data/modules/polls/images/icon.png.

$module_version

This variable defines the version of your module. You can of course decide for yourself what version numbering is best for your module. For the poll module, we use:

$module_version = "0.1";

$module_author

Using this variable, you can show the world you were the one creating that incredible module. For example:

$module_author = "John";

$module_website

This variable will be used in the administration center of pluck to show the user of the module to which website he can go to get more information about the module or about it's creator.

$module_website = "http://www.site.org";

$module_compatibility

This variable is quite important, and defines the compatibility of your module with specific versions of pluck. It may sometimes happen that changes are applied to the module system of pluck, and that these changes cause some modules to stop functioning properly. This variable defines which version(s) of pluck the module works correct with. You can use more pluck versions, seperated by a comma.

For example, if our module is compatible with pluck 4.6 and pluck 4.7, we use the following code:

$module_compatibility = "4.6,4.7";

Resulting code

The resulting code (don't forget <?php and ?>):

<?php
$module_name = "simple poll";
$module_intro = "create a poll for your visitors and let them vote";
$module_dir = "polls";
$module_icon = "images/icon.png";
$module_version = "0.1";
$module_author = "John";
$module_website = "http://www.site.org";
$module_compatibility = "4.6,4.7";
?>

Ok, let's go to the next chapter!

Now that we've told pluck all there is to know about our module, we can start implementing our first pages into the administration center. Go to the next chapter...

 
dev/modules/chapter_2.txt · Last modified: 2008/06/21 15:39 by sander
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki