ImpressCMS proudly uses SourceForge
ImpressCMS on Ohloh.net
[NewIndex :: Development :: Developing Modules :: This page]  
Tags: Development   Outdated   Tutorial  

Module Tutorial

Originally published here

Basic content of a module.

This tutorial will teach you how to build a simple module.

The first step is to download the blank module called tutorial.


Tutorial module
tutorial

Open the tutorial module and you will see it has 2 php files, 1 directory called images and inside that 1 image. This is all you need to start. Now open the file xoops_version.php in an editor. You can either use a wysiwyg editor such as dreamweaver or you can use something like php Designer or Maguma Open Studio (both are free).

<?php
// Tutorial Module
// Created by kaotik

$modversion['name'] = "Tutorial";
$modversion['version'] = 1.00;
$modversion['description'] = "This is a tutorial module to teach how to build a simple module";
$modversion['author'] = "KaotiK";
$modversion['credits'] = "KaotiK";
$modversion['help'] = "";
$modversion['license'] = "GPL see LICENSE";
$modversion['official'] = 0;
$modversion['image'] = "images/tutorial.png";
$modversion['dirname'] = "tutorial";

// Admin
$modversion['hasAdmin'] = 0;

// Menu
$modversion['hasMain'] = 1;
?>

Now let's go through what this all means.

<?php
// Tutorial Module
// Created by kaotik

The very first line starts php, meaning that anything below this will get processed as php. Important note: never have empty space before <?php or you will receive "headers already sent" errors.
The next 2 lines are comments stating the name of the module and who created it (in this case me).

$modversion['name'] = "Tutorial";
$modversion['version'] = 1.00;
$modversion['description'] = "This is a tutorial module to teach how to build a simple module";

These 3 are self evidente, meaning as their name implies, name, version and description.

$modversion['author'] = "KaotiK";
$modversion['credits'] = "KaotiK";
$modversion['help'] = "";

Author and credits are also evidente. Help (if used which in this case is not) should point to a file such as help.html or help.php

$modversion['license'] = "GPL see LICENSE";
$modversion['official'] = 0;
$modversion['image'] = "images/tutorial.png";
$modversion['dirname'] = "tutorial";

License is the license used for the module. Keep in mind the the core uses GPL meaning that your module also falls under the GPL license. You can read more about it here. Official is whether this is an official module or not. In most cases this is set to 0. Image is the module icon you see on the module administration menu. Dirname is the directory name for the module.

// Admin
$modversion['hasAdmin'] = 0;

// Menu
$modversion['hasMain'] = 1;
?>

hasAdmin=0 means there is no administration part to this module. Since I want the module to appear on the main menu I've set hasMain to 1. If I had set it to 0 then it wouldn't show up on main menu. If you set hasAdmin and hasMain both to 0, it will still show up on module administration allowing you to uninstall it. The last line stops php processing.
Important note: never leave empty space after ?> as this will cause unpredictable behaviour.

Next Part > Using Smarty Templates

Last modified on 2010/11/27 by fiammybe
This page was created on 2010/11/11 by skenow
This page has been viewed 3255 time(s)

Comments
The comments are owned by the poster. We aren't responsible for their content.
ImpressCMS proudly uses SourceForge
ImpressCMS on Ohloh.net