Carrington Build Documentation

Construct

Use the module constructor to define the module’s options & ID.

The icon location and module description are defined in the constructor of the module. When registering your module’s options point to the module location relative to the location of the module’s include directory when defining the icon. For example, if your module structure looks like this:

- modules/
	- my_module/
		- my_module.php
		- my-icon.png

 

Your constructor should look like this:

class my_build_module extends cfct_build_module {
	public function __construct() {
		$opts = array(
			'description' => _('My Module Description.'),
			'icon' => 'my_module/my-icon.png'
		)
		parent::__construct('my-module-id', __('My Module Name'), $opts);
	}

	// ...
}

 

The icon path will first be checked to see if it is a full URL, if not it will be prepended with the module’s include directory url. Provide a full url, including the `http://` to define the full url to an icon file that’s outside of the normal Carrington Build structure.

Construct is also a good place to do any additional setup for the module.

“Autofocus” on First Form Element

By default each module is loaded with a helper JavaScript function that attempts to apply focus to the first visible element in the Module Admin Form that is a text input element. To apply focus to a custom element use Construct to define the `$focus_target` member variable to the ID of the form element that you want to be the autofocus target. Set to the ID to a bogus element (ie: point it to an element that doesn’t exist) to not use the autofocus functionality.

PHP 5 Is Required

Carrington Build does not support PHP4 and, as a result, does not support old style PHP4 constructors. Use the function name `__construct()` when defining your constructor.

See also:

Back to Carrington Build

These sections are available to the public. The remaining sections are available exclusively to customers.