Jump to content

Developer Documentation

Featuring content with Content Items

How to implement featuring

To support featuring content items in your application, you first need to implement the interface in your content item model:

implements \IPS\Content\Featurable

Next, you need to add a featured key to your $databaseColumnMap, with the value being the name of the column in your database table that stores the featured status of the item.

Finally, you need to add support to your templates. For example:

{{if $item->canFeature()}}
	<a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'feature' ) )}'>{lang="feature"}</a>
{{endif}}
{{if $item->canUnfeature()}}
	<a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'unfeature' ) )}'>{lang="unfeature"}</a>
{{endif}}

 

Changes after implementation

After implementing the \IPS\Content\Featurable interface, moderators with the appropriate permission will be able to see and use tools to feature content when selecting items in content item tables.

 

Additional model methods available

\IPS\Patterns\AciveRecordIterator static featured( [ integer $limit [, string $order [, \IPS\Node\Model $container ] ] ] )

Returns featured items. If permissions are supported in your model, only the items the user has permission to view are returned.

  • $limit (integer, optional, default 10)
    Number of items to return.
  • $order (string, optional, default 'RAND()')
    Order clause to be used in the query.
  • $container (\IPS\Node\Model, optional, default NULL)
    If provided, only featured items from this container will be returned.

 

boolean canFeature( \IPS\Member $member )

Indicates whether the user has permission to feature the item. This method takes into account whether the item is already featured.

  • $member (\IPS\Member, optional)
    If provided, this member's permissions will be checked. By default, the currently-logged in member will be used.

 

boolean canUnfeature( \IPS\Member $member )

Indicates whether the user has permission to unfeature the item. This method takes into account whether the item is already unfeatured.

  • $member (\IPS\Member, optional)
    If provided, this member's permissions will be checked. By default, the currently-logged in member will be used.

  Report Document


×
×
  • Create New...