Documentation

Features

This is an old revision of the document!


Modules

Modules allow to create extra functionality that does not touch the core files of 68 Classifieds. Thus enabling your module to not get overwritten during upgrades.

Module Requirements

  1. Each module must be contained in a single directory.
  2. Each module must have a config.php file that includes needed information.
  3. The users should be able to activate and use the module from the “Modules” menu in the administrative. Optimally, a module should not require users to modify the source code.
  4. If the module is going to interact with 68 Classifieds hook system it must contain a file mod_user.php and all functions must include the module name before the hook. For example: my_module_start() is a valid function name where start() is not. If you name your function incorrectly it will not cause problems except it will never be called through the script.
  5. If needed inside the modules directory it can have a templates, language, and plugins directory. The templates directory would contain any template files needed. The language directory allows your module to work for multiple language. Please be careful not to name a language string the same as the standard language file. The plugins directory is to place any Smarty plugins that you would like to use for this module.
  6. index.php and admin.php and used if the module has a frontend area or an administration section. These are only required if the user needs to have some of interaction with the module.
  7. You may include any other files that the module may need to interact with.

Module Tutorial

This is intended to be a short tutorial on creating a module.

Naming Your Module

The first step is to name your module. We will be building a module that allows you to specify a custom showlisting file when viewing a category. We will name this module “Custom Cats”. So we create a directory inside the modules folder named customcats.

Create A Module Folder

Once we have the name of our module, we need to create a folder for it in the modules folder. The name of this folder should be a lowercased and space-less version of the module's name. Instead of spaces, you should either use a single word for your module or underscores. For our example, we will create a folder called “customcats” that would be located like so: /modules/customcats/.

Create a configuration file

We will need to create a new php file named config.php that will reside in the /modules/bad_words folder .

The config.php file should look like this:

<?php
	$data['module']['name'] = "customcats";
	$data['module']['displayname'] = "Custom Categories";
	$data['module']['description'] = "Allows you to use custom category template files.";
	$data['module']['version'] = "v1";
	$data['module']['admin_capable'] = "1";
	$data['module']['user_capable'] = "0";
?>

These variables should be pretty self explanatory. However the name should only contain letters, numbers, dashes, or hyphens. Do not enter any spaces here. The version is your internal version number separate from 68 Classifieds. The admin_capable and user_capable determine if the module should be accessed from either location. Since the admin_capable has a value of 1 that means it can be accessed through the administration. Where as the user_capable has a 0 which means this module only includes an admin file.

Create an init.php file

The init.php file is responsible for installing items into the database and uninstalling if the user decides to remove the module.

The init.php file can have three functions and they are:

install()
upgrade()
uninstall()

These functions are not required if you do not need to insert any items into the database.

For our module this file will include the following code:

<?php
	function install()
	{
		global $db, $class_tpl;
		$sSQL="ALTER TABLE `".PREFIX."categories` ADD `ccTemplate` VARCHAR( 255 ) NOT NULL ;";
		$db->query($sSQL);
		$class_tpl->assign('msg', 'Everything installed successfully.');
	}
?>

Have more questions? Visit our community forums.