Jadu is installed with a set of standard supplements, however the facility exists to create bespoke supplements. Creating a page supplement for your website involves four steps, as follows:
- Create a database table to store data for your supplement
- Create a custom class file which inserts, updates and deletes records in the above table
- Create a Control Center file where an administrator can manage supplements
- Create a front end script to display the supplement
Supplement database table
The syntax of the table can be derived from an already existing Jadu supplement table, and then altered to reflect the data that you wish to save. The basic SQL template for a custom supplement is as follows:
CREATE TABLE 'MyCustomPageSupplement' ( 'id' int(11) NOT NULL auto _ increment, 'title' varchar(100) NOT NULL, 'field1' varchar(50) default NULL, 'field2' varchar(100) default NULL PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
The supplement must have a field named
title. The database column data types and sizes should be chosen to best suit the data which you are wanting to insert into the table. If you are displaying a textarea allowing the administrator to type an infinite number of characters, a data type of
nvarchar(MAX) is preferred instead of a fixed length column.
Available supplements table
JaduPageSupplementWidgets database table informs Continuum CMS what supplements are available. Specific columns in this database table such as
classFile are paths to files. The value of these columns must be case sensitive and relative paths from a particular directory. If the file cannot be found from the path defined then a fatal error will be generated.
Insert a record into the
JaduPageSupplementWidgets table representing your supplement to make it available in Continuum CMS.
Below is a quick review of the table columns.
title- this is the name that you want the custom page supplement to be referred to as
classFile- this path is relative to the
jadutop level directory
className- this is the name given to your class file object
controlCentreFile- this path is relative to the
Supplement template table
JaduPageSupplementPublicCode table tells Continuum CMS which in location a page supplements can appear on a website.
By default there are three predefined locations:
You will need to insert one record for each location available to your supplement.
Code column should contain the front end template filename without the file extension.
After adding records, the respective caches must be cleared before those changes will take effect. This can be done using the
The class file should follow the principles laid out in the Datamapper section. The attributes of the class file should match the columns of the database table.
As well as methods to create, read, update and delete a record, additional methods that select by a particular field are required in order to refine results sets. These methods are used in the Control Center to manage the custom page supplements.
The supplements admin interface is included in a parent document, as such only HTML table row elements are required.
This file should allow an adminstrator to:
- enter new content
- retrieve and update existing content
- delete old content
After updating the supplement's database table, you must then update the CMS supplement table when inserting or deleting. To update
JaduPageSupplements, instantiate a new
PageSupplement object and assign appropriate values to the attributes of the object.
Key attributes of the
PageSupplement object are detailed below:
contentType- this is passed into the parent script as a
GETparameter and can easily be accessed by
itemID- this is passed into the parent script as a
GETparameter and can easily be accessed by
widgetID- this is the ID of the page supplement from the
supplementRecordID- this is the of the saved record into the custom table
locationOnPage- this would be where abouts on the front end page the supplement should appear such as 'bottom'
Once you have assigned all the appropriate values to the attributes of the object, save the record by passing the instantiated
PageSupplement object in as a parameter to the
A PHP script should be created in the
site/includes/supplements directory. The file name should be prefixed by the name of the client.
The front end script will follow the same procedure as the Control Center file in that it outputs a small HTML snippet.
You will be able to access the attributes of your supplement class by using the already existing instantiated object which is defined as
Ensure that you escape HTML characters in all variables that are output using the
encodeHTML function. This is to ensure there are no cross site scripting (XSS) vulnerabilities.
<?php print encodeHtml($myVariable); ?>