Jump to content

Developer Documentation

Implementing the follow system in Content Items

How to implement following

Note: Your application must also implement searching (\IPS\Content\Searchable) in order to implement following.

The first step is to implement the followable interface in your content item model, like so:

implements \IPS\Content\Followable

Next, you need to insert the template includes that will display the follow button inside your nodes and inside the content items themselves. In your node view (e.g. forum view), insert this tag:

{template="follow" app="core" group="global" params=“'yourApp','yourNodeClass', $node->_id, \IPS\yourApp\YourContentClass::containerFollowers( $node )->count( TRUE )"}

In this tag, the params are:

  • yourApp - your application key
  • yourNodeClass - the name of your container node class
  • $node->_id - the ID of your container (e.g. the forum, in the Forums app)
  • The final param should statically call the containerFollowers (see below) on your content item class in order to pass in the current number of followers.

In your content item view (e.g. topic topic), insert this tag:

{template="follow" app="core" group="global" params="'yourApp', 'yourContentItemClass', $item->id, $item->followersCount()"}

In this tag, the params are:

  • yourApp - your application key
  • yourContentItemClass - the name of your content item class
  • $item->id - the ID of the relevant content item
  • The final parameter simply calls $item->followersCount() to pass in the current number of followers.

 

Changes after implementation

  • After posting a new content item, members who are following the node it was posted into will receive a notification. If the content needs to be approved by a moderator, the notifications will be delayed until the content has been approved.

 

Additional model methods available

integer static containerFollowers\IPS\Node\Model $node [, integer $privacy [, array $frequencyTypes [, \IPS\DateTime $date [, integer|array $limit [, string $order [, integer $flags ] ] ] ] ] ] )

Returns the followers of a node.

  • $node (\IPS\Node\Model, required)
    The node from which followers will be returned.
  • $privacy (integer, optional, default 3)
    bitwise value representing the types of follows that should be returned (see below for more information). The default value 3 includes both anonymous and public followers.
  • $frequencyTypes (array, optional, default array( 'none', 'immediate', 'daily', 'weekly' ) )
    Allows you to narrow the returned followers to specific types of follow. By default, all types are counted.
  • $limit (integer or NULL, optional, default NULL)
    Allows you to limit the number of followers returned. Value is passed as the LIMIT clause in the resulting query.
  • $order (string, optional, default NULL)
    Allows you to determine the column on which the results will be ordered.
  • $flags (integer or NULL, optional, default NULL)
    SQL flags that will be passed to \IPS\Db when the underlying query is performed.

 

Bitwise follow privacy values

The privacy setting on follows allows a user to specify whether their follow should be 'public' or 'anonymous' - meaning their follow counts towards the total, but they won't be listed by name. The values are:

const FOLLOW_PUBLIC = 1;
const FOLLOW_ANONYMOUS = 2;

 


  Report Document


×
×
  • Create New...