Creating Subtypes

You can create new classes for Ariadne in two ways. The first has always been available and involves creating a new system wide class in PHP. This involves extending Ariadne. Objects of this type can only be imported in another Ariadne system if it too is extended with the PHP code containing the class definition.

The second way is through subtypes. These can be defined through PINP templates and can be imported in any Ariadne system. The subtypes 'extend' an existing Ariadne class without the need for a low-level PHP class definition. This makes it much easier to create your own set of content classes while keeping the site or application easily portable between Ariane installations.

The TypeTree

Ariadne in principle allows you to create any kind of object as a child of another object. However this can quickly become difficult to maintain. So we've introduced the typetree. This is a system that allows you to tell Ariadne which kinds of objects may be created as a child of another kind of object. In this way you can specify that photobooks may only contain photo's and other photobooks. When an editor wants to create a new object below a photobook only the photo and photobook type are listed. As administrator, or even in PINP templates, you still have the option to create any kind of object anywhere you like.

The default typetree can be changed through the typetree.ini template. This template defines the new typetree for the rest of the content tree (children of the object on which the template is defined). But you can also use it to create new subtypes. A typical typetree.ini template will look something like this:

$arTypeTree = getvar('arTypeTree');
$arTypeTree['psite'][''] = 'Contact Section';
putvar('arTypeTree', $arTypeTree);

$arTypeNames = getvar('arTypeNames');
$arTypeNames[''] = 'Contact Section';
putvar('arTypeNames', $arTypeNames);

$arTypeIcons = getvar('arTypeIcons');
$arTypeIcons[''] = $arTypeIcons['psection'];
putvar('arTypeIcons', $arTypeIcons);

This template adds a subtype with the name 'Contact Section' to the typetree. It can only be added as a child of a psite object. The $arTypeNames is used to define the name of the subtype, independent of its place in the typetree, e.g. when writing a pinp template for it. The $arTypeIcons defines the icons to use to display this subtype. In this case the same as its real type, psection. Read more about the typetree.ini template here.

When creating new objects of this subtype, you will still see the same wizard as the real type has. You can however change this and extend the wizard or create a completely new one. Read the second part of the tutorial about defining workflows for more information on that.