Jump to content

Developer Documentation

Pinning content with Content Items

How to implement pinning

In order to support pinning content items in your model, you need to implement the following interface:

implements \IPS\Content\Pinnable

Next, you should add a pinned key to your $databaseColumnMap, with the value being the name of the database column that stores the pinned status of your items.

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

{{if $item->canPin()}}
	<a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'pin' ) )}'>{lang="pin"}</a>
{{endif}}
{{if $item->canUnpin()}}
	<a href='{$item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'unpin' ) )}'>{lang="unpin"}</a>
{{endif}}

 

Changes after implementation

  • Pinned items will appear at the top of the content item table views
  • Moderators with the appropriate permission will be able to see and use tools to pin content when selecting items in content item tables.

 

Additional model methods available

boolean canPin\IPS\Member $member )

Indicates whether the user has permission to pin items. This method takes into account whether the item is already pinned.

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

 

boolean canUnpin( \IPS\Member $member )

Indicates whether the user has permission to unpin items. This method takes into account whether the item is already unpinned.

  • $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...