Jump to content

Condition for reputation - Pages

Featured Replies

Posted

Hey,
I need to find a condition for the element to appear when it receives a reaction.

I tried the following code, but the item appears despite not receiving a reaction to the record.

{{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled}}
	test
{{endif}}

 

{{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND \count( $record->reactions() )}}
	Has had at least one reaction
{{endif}}

 

Hello,

You can also use $record->reactionCount()

{{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND $record->reactionCount()}}
	
{{endif}}

 

9 hours ago, newbie LAC said:

Hello,

You can also use $record->reactionCount()


{{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND $record->reactionCount()}}
	
{{endif}}

 

Actually, reactionCount is the overall value of all reactions. So, if a record has a reaction, or number of reactions, that are neutral (does not increase a users reputation) then it will return zero.

the office oops GIF

4 minutes ago, Ryan Ashbrook said:

Actually, reactionCount is the overall value of all reactions. So, if a record has a reaction, or number of reactions, that are neutral (does not increase a users reputation) then it will return zero.

In this case the method should be called reactionSum and docblock should contain more detailed information

	/**
	 * Reaction Count
	 *
	 * @return int
	 */
	public function reactionCount()
	{

 

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.