Jump to content

Developer Documentation

Containers

In most situations, your Nodes will be a container for content items - this is the typical structure used by most apps. Node models and their content item models provide a number of methods for working with each other in this kind of relationship.

There are two parts to this relationship - the functionality that becomes available to the container (i.e. the node), and the functionality that becomes available to the content items within that node. This guide will deal with the first; see Content Items in Containers for information on functionality available to your content items.

 

Configuring your node model

In your node model, you need to specify the name of the content item model you're using.

public static $contentItemClass = 'string';

For example, in the Forum node model, we'd specify the content item model like so:

public static $contentItemClass = 'IPS\forums\Topic';

 

Configuring your content item model

In your content item model, you need to specify the name of the node model you're using.

public static $containerNodeClass = 'string';

For example, in the Topic node model, we'd specify the node model like so:

public static $containerNodeClass = 'IPS\forums\Forum';

In addition, you need to add a key named container to your $databaseColumnMap property, the value of which should be the column name in the database table that holds the ID to the node that is parent to each content item.

protected static $databaseColumnMap = array(
	'container' => 'parent_id',
	//other column maps...
);

 

Getters/setters available to the node model

After establishing the two-way binding, these additional getters and setters become available to your model class. They are all defined in the base node model class, and by default, all of the get__* methods return NULL, while all of the set__* methods do nothing. You can override them in your own node class if you need to keep track of the values.

 


  Report Document


×
×
  • Create New...