Basics
You can extend Pages, Files, Content Blocks and E-Mailings. Depending on what kind of object your code should extend you need to pick the corresponding Extension type.
Extensions can either get manually added to an object by a User, or can be added automatically to all objects of a type.
Each Extension can extend it's interface in the Extension administration panel and it's appearance on the Extensions tab when editing an object.
Additionally yeager offers Data Extensions, which can be used to export and import data from and into the system. These are solely controlled through the
Data administration panel.
Custom views for Content Blocks lists can be created by making use of Content Block List Extensions.
Installing Extensions
To install an Extension you need to copy the folder containing the Extension into the Extension directory you configured during the installation (e.g.
/frontend/extensions/extension_folder).
After copying the Extension to that folder you should be able to access it's interface from the
Extension administration. Before an Extension will become active you have to install it, using the "install" button from that administration panel.
File structure
An Extension has to follow a specific folder structure. The name of the Extension folder should be as unique as possible. The minimum required files for an Extension are:
/extension_folder/
/img/
icon.png
extension.php
extension.xml
extension.xml
The extension.xml is used to access basic information of your Extension, like your namespace, the api version and the name of the Extension class.
Please choose your namespace carefully, as it should not interfere with namespaces of other developers. Usually you pick your company name here.
<extension>
<namespace>com\yournamespace</namespace>
<class>extension_class_name</class>
<api>1.0</api>
</extension>
extension.php
The $info array defines how this Extension is handled by the system. Think of it as the basic configuration of your Extension. Following is an example of the minimum required code of an extension.php:
<?php
namespace com\yournamespace;
class extension_class_name extends \PageExtension {
public $info = array(
"NAME" => "Name of Extension",
"DEVELOPERNAME" => "Your name",
"VERSION" => "1.5",
"DESCRIPTION" => "A description goes here",
"URL" => "http://www.yourdomain.com",
"TYPE" => EXTENSION_PAGE,
"ASSIGNMENT" => EXTENSION_ASSIGNMENT_EXT_CONTROLLED
);
public function install() {
if (parent::install()) {
// custom code can go here
return parent::setInstalled();
} else {
return false;
}
}
public function uninstall() {
if ( parent::uninstall() ) {
// custom code can go here
return parent::setUnInstalled();
} else {
return false;
}
}
/*
public function onRender($args = NULL) {
// callback function called everytime a Page gets rendered
}
// other callbacks, custom functions, includes, etc.
*/
}
?>
TYPE
The
TYPE specified in
$info defines which type of objects will get extended.
TYPE may be any of the following values:
EXTENSION_PAGE
EXTENSION_CBLOCK
EXTENSION_CBLOCKLISTVIEW
EXTENSION_MAILING
EXTENSION_FILE
EXTENSION_IMPORT
EXTENSION_EXPORT
So, for example, an Extension of the type
EXTENSION_PAGE can only get assigned to Pages and it's callbacks are only executed when an action is performed on a Page this Extension is assigned to (see
callbacks functions).
The
TYPE also defines which class needs to get extended by your code:
// object Extensions
class CustomExt extends \PageExtension { } // TYPE: EXTENSION_PAGE
class CustomExt extends \CblockExtension { } // TYPE: EXTENSION_CBLOCK
class CustomExt extends \MailingExtension { } // TYPE: EXTENSION_MAILING
class CustomExt extends \FileExtension { } // TYPE: EXTENSION_FILE
// Content Block lists
class CustomExt extends \CblockListviewExtension { } // TYPE: EXTENSION_CBLOCKLISTVIEW
// data Extensions
class CustomExt extends \ImportExtension { } // TYPE: EXTENSION_IMPORT
class CustomExt extends \ExportExtension { } // TYPE: EXTENSION_EXPORT
ASSIGNMENT
The
ASSIGNMENT parameter defines how the Extension will have to get assigned to objects:
The following values (constants) are available:
EXTENSION_ASSIGNMENT_USER_CONTROLLED
EXTENSION_ASSIGNMENT_EXT_CONTROLLED
EXTENSION_ASSIGNMENT_USER_CONTROLLED defines that it is up to the User(s) to which objects this Extension gets attached to. Users will have to assign the Extensions manually to objects.
EXTENSION_ASSIGNMENT_EXT_CONTROLLED defines that the Extension is attached to all objects of the corresponding TYPE, so Users don't have to add it manually.
install() and uninstall()
Re-implementing the
install() and
uninstall() method is mandatory. You can add your custom code here to perform for instance one of the following actions:
- add/remove custom properties (to generate form fields for the Extension)
- create/remove/fill database tables
- etc.
Adding and accessing Extension properties
yeager allows you to customize the form fields which are exposed to the Users in the Extension administration panel and on an object's Extension tab. Detailed information on that topic is availabel at
Properties.
Callbacks
By defining callback functions in an Extension your custom code gets executed whenever the corresponding action is performed on an object.
Please head over to
callback functions to see which callbacks are available for each Extension type.
Checkout the API
Extending objects:
Extending the Content Block administration UI:
Export and Import Extensions: