What it does
Since a lot of functionality in the IPS Community Suite (such as reports, warnings, and more) is handled centrally, other applications (both IPS and third-party) need some way to register themselves with the core so that it can be handled appropriately. The ContentRouter extension is where this happens.
At its most basic, the ContentRouter simply registers the content item classes so that the core can work with them.
For more information on the ContentRouter, consult this step of the Content Items guide.
How it works
At its most basic, only one class property needs to be defined: $classes. That said, this extension supports some other less-used capabilities as well.
* @brief Content Item Classes
public $classes = array();
The $classes array defines the content item classes supported by the extension. Typically, this is populated by the constructor after checking member permissions to ensure that the current viewing member can access the content items as well.
* @brief Owned Node Classes
public $ownedNodes = array( 'IPS\blog\Blog' );
If your application supports owned nodes (for instance, blogs and gallery albums are nodes which are owned by members) you should define the node classes here.
* @brief Embeddable Classes
public $embeddableContent = array();
If your application supports a type of embeddable content that is not a content item (implementing \IPS\Content\Embeddable) you can define it using the $embeddableContent type. Some practical examples include clubs and commerce product reviews. Note that your class will need to implement \IPS\Content\Embeddable (even if it is not a content item), will need to support a url() method, a loadFromUrl() method, and will need to represent the embedded content output when called with the ?do=embed query string parameter.
* @param \IPS\Member|IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
* @return void
public function __construct( $member = NULL )
if ( $member === NULL or $member->canAccessModule( \IPS\Application\Module::get( 'blog', 'blogs', 'front' ) ) )
$this->classes = 'IPS\blog\Entry';
The constructor is passed a member or group object (or NULL), and it is expected that your extension verifies the member or group (if supplied) has access to the content item classes before the $classes property is populated. In the example above, you will see that we only populate the blog Entry content item class if we are not checking permissions, or if the member can access blog entries.
* Use a custom table helper when building content item tables
* @param string $className The content item class
* @param \IPS\Http\Url $url The URL to use for the table
* @param array $where Custom where clause to pass to the table helper
* @return \IPS\Helpers\Table|void Custom table helper class to use
public function customTableHelper( $className, $url, $where=array() )
// Adjust table, etc.
The customTableHelper() method allows you to adjust certain tables of content items that are centrally generated, if needed. You may wish to add an extra CSS class to the table so you can style it differently, for example, and this method allows you to do that. Gallery uses this method to ensure the content item tables generated centrally still display images in an expected fashion, for instance.