Jump to content

Community

Developer Documentation

Supporting reputation in Content Items

How to implement reputation

You first need to implement the reputation interface in your model, like so:

implements \IPS\Content\Reputation

Next, you need to add a static property to your content item model which distinguishes this type of reputation from that on another kind of content. It can be anything you like, but the convention is to use the column name that stores the item ID (for example, topic_id or entry_id).

public static $reputationType = 'string';

Finally, add the reputation buttons by calling the reputation button template in your content item view:

{template="reputation" app="core" group="global" params=“$item"}

 

Additional model methods available

boolean canGiveReputationinteger $type [, \IPS\Member $member ] )

Indicates whether the user can give reputation to the creator of the content item.

  • $type (integer, required)
    The type of reputation to be given. Either 1 or -1, where 1 is positive reputation and -1 is negative reputation.
  • $member (\IPS\Member, optional)
    The member whose permissions should be used when checking. By default, the currently-logged in member will be used.

 

void giveReputationinteger $type [, \IPS\Member $member ] )

Gives reputation to the creator of the content item. Throws a DomainException if the member does not have permission to give reputation to this item.

  • $type (integer, required)
    The type of reputation to be given. Either 1 or -1, where 1 is positive reputation and -1 is negative reputation.
  • $member (\IPS\Member, optional)
    The member whose permissions should be used when checking. By default, the currently-logged in member will be used.

 

integer repGiven( [ \IPS\Member $member ] )

Returns a value indicating whether (and what type of) reputation the member has given to the item. The return values are:

  • 1 - positive reputation has been given
  • -1 - negative reputation has been given
  • 0 - no reputation has been given

 

  • $member (\IPS\Member, optional)
    The member whose permissions should be used when checking. By default, the currently-logged in member will be used.

  Report Document


×
×
  • Create New...