FUEL CMS User Guide : Version 0.9.3


Base_module_model

The Base_module_model is the base abstract class that should be extended when creating modules. The class should be required at the top of your module like so:

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once(FUEL_PATH.'models/base_module_model.php');

class My_super_model extends Base_module_model {
...

Configuring Base_module_model Information

There are several public properties you can use to configure the Base_module_model Class:

Preference Default Value Options Description
filters array() None Field names of where to search for items
filter_value NULL None The values of the filters. Set automatically when filters are selected
filter_join or and, or How to combine filters in the list_items method query
parsed_fields array() None Fields to automatically do template parsing
upload_data array() None Data about all uploaded files. Set after uploads


Base_module_model Function Reference

The Base_module_model is a table class and returns Base_module_record objects (see reference below).

$this->module->get_table(table)

Gets the table name based on the configuration.

$this->module->add_filter(filter, [key])

Adds a filter for searching.

$this->module->add_filters(filters)

Adds multiple filters for searching.

$this->module->list_items([limit], [offset], [col], [order])

Returns an associative array of the table records and is used by the Data_table class to display the module's items in the list view. By default it will list all columns. To filter out columns, simply override this method and use CodeIgniter's Active Record select statement like so:

...
function list_items($limit=NULL, $offset=NULL, $col = "name", $order = "asc")
{
	$this->db->select('id, name', published');
	parent::list_items($limit, $offset, $col, $order);
}
...

You should always include the primary key id in this select so the Data_table object can use it in the table row's edit and delete actions.

$this->module->list_items_total()

Lists the total number of module items. Used in calculating the number of pages when paginating.

$this->module->archive(ref_id, data)

Saves data to the archive.

$this->module->get_last_archive(ref_id, [all_data])

Retrieves the last archived value.

$this->module->get_archive(ref_id, [version], [all_data])

Retrieves an archived value.

$this->module->restore(ref_id, [version])

Restores module item from an archived value.

$this->module->get_others('display_field', id, [val_field])

Get other listed module items excluding the currently displayed.

$this->module->form_fields([values], [related])

Overwrites MY_Model's form_field() method and adds some additional features including automatically creating image upload fields for table column names that end with image or img.


Base_module_record Function Reference

The Base_module_record class is what is returned by module table classes and extends the Data_record class.

set_parsed_fields()

Sets the fields to parse.

get_parsed_fields()

Returns the fields to parse.

after_get()

A hook method that gets called after a value is returned by the class. This method will parse any fields that have been set to be parsed.