Exponent Modules Guidelines

From Fishcakes Wiki

Jump to: navigation, search
Edit Menu

Image:Icon_Exponent_40px.png Exponent Modules Guidelines

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


Contents

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 addressbook_contact table.

return array(
   'id'=>array(
      DB_FIELD_TYPE=>DB_DEF_ID,
      DB_PRIMARY=>true,
      DB_INCREMENT=>true),
   'user_id'=>array(
      DB_FIELD_TYPE=>DB_DEF_ID),
   'firstname'=>array(
      DB_FIELD_TYPE=>DB_DEF_STRING,
      DB_FIELD_LEN=>100),
   // etc //
   'location_data'=>array(
      DB_FIELD_TYPE=>DB_DEF_STRING,
      DB_FIELD_LEN=>200,
      DB_INDEX=>10)
);

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

return array(
   // etc //
   'location_data'=>array(
      DB_FIELD_TYPE=>DB_DEF_STRING,
      DB_FIELD_LEN=>200,
      DB_INDEX=>10),
   'mynewfield'=>array(
      DB_FIELD_TYPE=>DB_DEF_STRING,
      DB_FIELD_LEN=>200,
      DB_INDEX=>10)
);

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)

<td class="header addressbook_header">variable name</td>

6. Goto \_view.tpl and add<tr> (this adds field in the detail view) <tr>

<td valign="top">variable name</td>
      <td valign="top">{$contact->variable name}</td>
</tr>

Modules

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:

$template->assign('backlink',exponent_flow_get());

Then, edit the view file:

modules/yourmodule/views/your_view.tpl

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

<a href="{$backlink}">back to previous page</a><br>

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:

$backlink = (exponent_flow_get());

Then add this at bottom of code after template new:

$template->assign('backlink',$backlink);

Then, edit the view file:

modules/yourmodule/views/your_view.tpl

add:

<a href="{$backlink}">back to previous page</a><br>


Notes

found solution in formbuilder module

susbsystem/flow.php
susbsystem/flow.info.php
susbsystem/flow.manifest.php

This saves the current URL in the variable:

exponent_flow_set
exponent_flow_set($access_level,$url_type)

It returns the last URL set:

exponent_flow_get
exponent_flow_get($url_type = SYS_FLOW_NONE)

Or return the last 'valid' URL visited:

exponent_flow_redirect
exponent_flow_redirect($url_type = SYS_FLOW_NONE)

See also Dan's Forum Post — contains help from another user plus a guide to what I did.

Subsystems

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:

// archive url target list
'target'=>'Page Target',
  'blank'=>'Target _blank',
  'java'=>'Target javascript',

Then, edit file:

datatypes/showreel_project.php
// dropdowncontrol definitions in subsystems/lang/eng_US/datatypes/showreelmodule.php
 $targetlist  = array('BLANK'=>$i18n['blank'],'JAVA'=>$i18n['java']);
 $form->register('archurltarget',$i18n['target'],new dropdowncontrol($object->archurltarget,$targetlist));

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 views folder of some modules there's a file Default.form 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


Image:Icon Resources 20px.png Exponent CMS Resources

Official Exponent Resources


Unofficial Exponent Resources

MySQL Resources

PHP Resources


Personal tools