aXenDev Posted August 26, 2019 Posted August 26, 2019 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}}
Ryan Ashbrook Posted August 26, 2019 Posted August 26, 2019 {{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND \count( $record->reactions() )}} Has had at least one reaction {{endif}}
newbie LAC Posted August 27, 2019 Posted August 27, 2019 Hello, You can also use $record->reactionCount() {{if \IPS\IPS::classUsesTrait( $record, 'IPS\Content\Reactable' ) and settings.reputation_enabled AND $record->reactionCount()}} {{endif}}
Ryan Ashbrook Posted August 27, 2019 Posted August 27, 2019 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.
newbie LAC Posted August 27, 2019 Posted August 27, 2019 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() {
Recommended Posts
Archived
This topic is now archived and is closed to further replies.