Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted August 26, 20195 yr 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}}
August 26, 20195 yr {{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND \count( $record->reactions() )}} Has had at least one reaction {{endif}}
August 27, 20195 yr Hello, You can also use $record->reactionCount() {{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND $record->reactionCount()}} {{endif}}
August 27, 20195 yr 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.
August 27, 20195 yr 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.