Jump to content

Developer Documentation

Content router extensions for Content Items

Many features of IPS4 are handled centrally and automatically, such as warnings and moderator permissions. In order to support this, you need to register your content item types with the core, and this is done via a simple Content Router extension. For more information on the extensions, see the extensions guide.

In order for this functionality to work, you need to support containers in your content items and in your node models.


How to implement a ContentRouter extension

The first step to implementing your content router is to create the ContentRouter extension in the Developer Center of your application. The classname should be relevant to your model's purpose, for example Topics. Open the created file, and add code like this (changing the values as appropriate):

namespace IPS\yourApp\extensions\core\ContentRouter;

class _YourClass 
    public $classes = array( 'IPS\yourApp\YourContentItemClass' );

Next, add the following property to your node model (not the content item model):

static $modPerm = 'string';

The value is used as the key to store nodes that a moderator has permission to work with. It can be anything you like. Create a language string in your lang.php file with this same key - this will be the textual representation of what your nodes are called (for example, 'Categories').

Finally, add a language string to your lang.php file for each of the moderation actions, using this format:


where <title> is the key defined by the static $title property from your content item model. The actions you'll need to define will depend on which content item features you support in your model, but may include:

  • pin and unpin (if pinning is supported)
  • feature and unfeature (if featuring is supported)
  • hideunhide and view_hidden (if hiding and approving is supported)
  • lockunlock and reply_to_locked (if locking is supported)
  • edit
  • move
  • delete

Note: If your content item supports comments, repeat this last step for actions that can be performed on comments (edit, delete, hide, unhide and view_hidden), where <title> is the key defined by the static $title property from your content comment model.

As an example, assume the $title of our content item model is 'myapp_entry'. We would create language strings like this:

'can_edit_myapp_entry' => "Can edit entries?",
'can_move_myapp_entry' => "Can move entries?",
'can_delete_myapp_entry' => "Can delete entries?"

...and so on.


Behavior that changes after implementing a ContentRouter extension

  • When creating a moderator, administrators will be able to setup moderator permissions for your content items.
  • When viewing a user’s profile, showing all content posted by that user will include your content items.
  • If you support hidden content items, when viewing the moderator control panel, hidden content items from your application will be shown.
  • When a moderator gives a user a warning, if the warning was issued from a piece of content in your application, that content will be associated with the warning.
  • When rebuilding a member’s post count, your content items will be accounted for.
  • When deleting all content posted by a member, your content items will be accounted for.

  Report Document

  • Create New...