In most cases, your content items will exist inside container node structures that categorize them - for example. topics (item) in a forum (node), or images (item) in an album (node). A number of methods are available within the content item model to make working with these relationships easier.
Adding support for container nodes
The first step you need to take is add a new static property to your content item model.
This property value should be the name of your node's model class, allowing IPS4 to identify the relationship.
Next, you need to add a container key to the $databaseColumnMap array in your model (see the content item model guide for more information). The value should be the name of the database column that contains the ID number of the container.
Both parts are illustrated in this example:
protected static $containerNodeClass = "IPS\yourapp\YourNodeClass"; public static $databaseColumnMap = array( //... Other values defined in your column map 'container' => 'item_parent_id' );
Additional methods available to content item models
After adding support for containers, two methods become available:
Returns a boolean indicating whether the provided user can move the item to a different container.
-
$member (\IPS\Member, optional)
The member whose permissions should be used. By default, the currently-logged in member is used.
Moves the item into a different container. Note: this method does not check permissions; use canMove() first.
-
$container (\IPS\Node\Model, required)
The container node object into which the item will be moved. -
$keepLink (boolean, optional, default FALSE)
If true, a dummy content item will be added that links to the new location of the old content item.
Additional methods are also available to the container node model to help you work with collections of items; consult the container node model documentation for more details.
Report Document