Exponent Modules Guidelines

   Exponent Modules Guidelines

This page contains a guide to creating and customising Exponent Modules.

Adding Fields to a Module
Steps for adding a field (aka a variable) to a module: To add, remove or edit fields of any module, you have to edit the Definition file and the Datatype file. You will then need to add any new fields to your View templates so that they appear on your site.

For the Address Book module you'll need to edit the following files: /datatypes/definitions/addressbook_contact.php     (definition file) /datatypes/addressbook_contact.php                 (datatype file) /modules/addressbookmodule/Default.tpl             (default view file)

Editing the Definition File
The Definition file is where the fields which will be created in the Exponent database table for the module are defined. In this case the  table.

To add a new field to the module, you need to add the field to the array:

Remember that all the fields in the array must have a comma after the definition string, except for the last field.

There are different kinds of fields you can define such as strings (for text) or numeric, or dates, etc. NEED TO FIND FULL LIST DEFINED BY EXPONENT.

(the field appears 3 times in the file)

under folders datatypes and definitions:

a. Goto the data types folder and change the particular php files.

$object->variable name=' '; $form->register('variable name',TR_ADDRESSBOOKMODULE_VARIABLE NAME,new textcontrol($object->variable name)); $object->variable name = $values['variable name'];

b. Goto the definitions folder and change the particular php files in

'variable_name'=>array(DB_FIELD_TYPE=>DB_DEF_STRING, DB_FIELD_LEN=>100),

2. Go to the exponent site and login as administrator. In the admin module, click on "Install Table"

3. Go to subsystems\lang\en\modules\addressbookmodule.php

4. Define your variable:

define('TR_ADDRESSBOOKMODULE_VARIABLE NAME',             'variable name');

5. Change the template files in: \modules\addressbookmodule\views\default.tpl in the header(this adds field in the default view)

variable name

6. Goto \_view.tpl and add (this adds field in the detail view) variable name

{$contact->variable name}


 * See Exponent Forum — Adding Variables to a Module.

Adding a 'Back' Button
You can't really add a 'Back' button in Exponent, but you can add a 'Return to Previous Page' button which should work in most cases.

Simple Solution
For some modules this is very simple. Just edit the action file modules/yourmodule/actions/your_action.php

Add the following code after template new:

Then, edit the view file: modules/yourmodule/views/your_view.tpl

Add the following code where you want the link to appear:

Complex Solution
For some more complex modules it's a bit more work. First edit the action file: modules/yourmodule/actions/your_action.php Add this at top of code before URL (loc) is reset:

Then add this at bottom of code after template new:

Then, edit the view file: modules/yourmodule/views/your_view.tpl add:

Dropdown Control (dropdowncontrol)
To create a dropdown list you need to edit the module Definitions and any subsystem files. This is an example of adding a dropdown to the Portfolio Module.

Edit file: subsystems/lang/en_US/datatypes/portfoliomodule_config.php

Add the dropdown variables:

Then, edit file: datatypes/showreel_project.php

INCOMPLETE — THIS NEEDS MORE WORK

Sort Subsystem
look in subsystems/sort.php for definitions of sort types by variable name usort($projects,'exponent_sorting_byNameAscending'); usort($projects,'exponent_sorting_byNameDescending'); usort($projects,'exponent_sorting_byRankAscending'); usort($projects,'exponent_sorting_byRankDescending'); usort($projects,'exponent_sorting_byUserNameAscending'); usort($projects,'exponent_sorting_byUserNameDescending'); usort($projects,'exponent_sorting_byPostedAscending'); usort($projects,'exponent_sorting_byPostedDescending'); usort($projects,'exponent_sorting_byUpdatedAscending'); usort($projects,'exponent_sorting_byUpdatedDescending');

If you want to call a sort function you need to load the sort subsystem by adding the following line before the sort into the class.php or action/action_name.php file: if (!defined("SYS_SORTING")) require_once(BASE."subsystems/sorting.php");

Default.form
In the  folder of some modules there's a file   which calls some sort of subsystems/template.php function used in module configuration. Need to find out what this is all about as can't find in documentation.

Mime Types

 * Forum Thread — fixing problems with Mime Type icon display.

Exponent Modules See Also

 * Download Modules
 * Developers Guide — doesn't really exist yet!
 * How To Create a Module — basic module structure explained.
 * Writing an Exponent CMS Module — good starting point by Jason York.