How To Develop A New Plugin
Oscailt has a component based architecture which allows a page to be built up from a number of different objects. There are three different types of oscailt object:
- Elements - Basic components intended to be viewed as part of a page, eg links, picture boxes etc
- Layouts - Components concerned with the general structure of a page, eg , pages lists, and bars
- Modules - The main components which provide some unique piece of functionality, eg newswire, gallery, etc
Each object can be placed in multiple contexts (eg full page in the centre pane, in a menu on a sidebar etc) and displays its content in a manner suitable to that context.
Oscailt comes with many objects which facilitate the basic working of a site but thanks to the modular architecture you can also write your own plugins to provide any new visual element you may require. Please remember that if your plugin is generally useful you should submit it to the Oscailt development team for inclusion in the next release.
Steps to Create A New Plugin
For this example example lets create a new object called "HelloWorld"
Create XML Descriptor
Create helloworld.xml in \xmldata\indydatatypes
This file contains any basic data that you want your module to have access to. It also contains a list of the input that the module will accept from the user and how to process it. For a full description of the format of these xml files, see the OscailtDevXMLDescriptor
Create Object Code
Create indyhelloworld.inc \objects\indyobjects\indydataclasses
This file basically takes care of reading in the data from the user and turning it into a chunk of code and / or HTML which will be viewed by the user. In general these classes can just inherit one of the built in object classes and implement a single function the getHTML
function. If the class is a container type (ie containing a list of other objects) it should inherit the indyList class, otherwise it should inherit the indyBasicObject class.
Modify \config\modules.php and add your object to the legal data types array, indicating whether your object is an element, layout or module. The division into elements, layouts and site modules is fairly arbitrary and merely provides a means of grouping similar types of object together.
Implement and required Runtime Objects
Where-ever possible objects should produce static HTML output. However, in many cases objects will need to access data at run time (for example by fetching the latest headelines from the database) and the object management system only updates the HTML produced by objects whenever the object is updated or re-cached. Therefore, many objects need to execute code at run-time.
To do this, oscailt provides a set of runtime display objects which include various functionalities that should be of use to many runtime objects. In general, oscailt modules which require runtime execution of code work in the following manner:
- indyhelloword.inc reads in data from user as defined by helloworld.xml
- the output of the getHTML function includes embedded PHP commands which include calls to runtime objects.
- these calls are generally structured in the same way to make processing easy.
For full information on this, see the OscailtDevRuntimeObjects
- 07 Aug 2005 added a basic skeleton of the procedure
- 07 Feb 2006 added some flesh