Related classes:
BxDolVotingQuery - votings database queries
BxBaseVotingView - votings base representation
BxTemplVotingView - custom template representation
AJAX votings for any content.
Big and small votings stars are supported
To add votings section to your site you need to add a record to 'sys_objects_vote' table:
ID - autoincremented id for internal usage
ObjectName - your unique module name, with vendor prefix, lowercase and spaces are underscored
TableRating - table name where sumarry votigs are stored
TableTrack - table name where each vote is stored
RowPrefix - row prefix for TableRating
MaxVotes - max vote number, 5 by default
PostName - post variable name with rating
IsDuplicate - number of seconds to not allow duplicate vote (for some bad reason it is define here)
IsOn - is this vote object enabled
ClassName - custom class name for HotOrNot @see BxDolRate
ClassFile - custom class path for HotOrNot
TriggerTable - table to be updated upon each vote
TriggerFieldRate - TriggerTable table field with average rate
TriggerFieldRateCount - TriggerTable table field with votes count
TriggerFieldId - TriggerTable table field with unique record id, primary key
OverrideClassName - your custom class name, if you overrride default class
OverrideClassFile - your custom class path
You can refer to BoonEx modules for sample record in this table.
Example of usage:
After filling in the table you can show big votings in any place, using the following code:
bx_import('BxTemplVotingView');
$o = new BxTemplVotingView ('value of ObjectName field', $iYourEntryId);
if (!$o->isEnabled()) return '';
echo $o->getBigVoting (1); // 1 - rate is allowed
And small votings, using the following code:
$o = new BxTemplVotingView ('value of ObjectName field', $iYourEntryId);
if (!$o->isEnabled()) return '';
echo $o->getSmallVoting (0); // 0 - rate is not allowed, like readony votings
In some cases votes are already in database and there is no need to execute additional query to get ratings,
so you can use the following code:
$o = new BxTemplVotingView ('value of ObjectName field', 0);
foreach ($aRecords as $aData)
echo $o->getJustVotingElement(0, $aData['ID'], $aData['voting_rate']);
Please note that you never need to use BxDolVoting class directly, use BxTemplVotingView instead.
Also if you override votings class with your own then make it child of BxTemplVotingView class.
Memberships/ACL:
vote - ACTION_ID_VOTE
Alerts:
Alerts type/unit - every module has own type/unit, it equals to ObjectName
The following alerts are rised
rate - comment was posted
$iObjectId - entry id
$iSenderId - rater user id
$aExtra['rate'] - rate