Getting started

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.
  1. <extension>
  2.     <namespace>com\yournamespace</namespace>
  3.     <class>extension_class_name</class>
  4.     <api>1.0</api>
  5. </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:
  1. <?php
  2.     namespace com\yournamespace;
  3.    
  4.     class extension_class_name extends \PageExtension {
  5.  
  6.         public $info = array(
  7.             "NAME" => "Name of Extension",
  8.             "DEVELOPERNAME" => "Your name",
  9.             "VERSION" => "1.5",
  10.             "DESCRIPTION" => "A description goes here",
  11.             "URL" => "http://www.yourdomain.com",
  12.             "TYPE" => EXTENSION_PAGE,
  13.             "ASSIGNMENT" => EXTENSION_ASSIGNMENT_EXT_CONTROLLED
  14.         );
  15.  
  16.         public function install() {
  17.             if (parent::install()) {
  18.                 // custom code can go here
  19.                 return parent::setInstalled();             
  20.             } else {
  21.                 return false;
  22.             }
  23.         }
  24.  
  25.         public function uninstall() {
  26.             if ( parent::uninstall() ) {
  27.                 // custom code can go here
  28.                 return parent::setUnInstalled();
  29.             } else {
  30.                 return false;
  31.             }
  32.         }
  33.  
  34.         /*
  35.         public function onRender($args = NULL) {
  36.             // callback function called everytime a Page gets rendered
  37.         }  
  38.    
  39.         // other callbacks, custom functions, includes, etc.
  40.         */
  41.  
  42.     }
  43. ?>

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:
  1. // object Extensions
  2. class CustomExt extends \PageExtension { }              // TYPE: EXTENSION_PAGE
  3. class CustomExt extends \CblockExtension { }            // TYPE: EXTENSION_CBLOCK
  4. class CustomExt extends \MailingExtension { }           // TYPE: EXTENSION_MAILING
  5. class CustomExt extends \FileExtension { }              // TYPE: EXTENSION_FILE
  6.  
  7. // Content Block lists
  8. class CustomExt extends \CblockListviewExtension { }    // TYPE: EXTENSION_CBLOCKLISTVIEW
  9.  
  10. // data Extensions
  11. class CustomExt extends \ImportExtension { }            // TYPE: EXTENSION_IMPORT
  12. 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