What is the logic and where can I find the column that shows the number of votes associated with the photo?
I saw that there are several tables and several columns but I can't understand which one I should use to display the total number of votes.
Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Latest post by b2z on Thursday, 21 March 2024 10:48 EET
What is the logic and where can I find the column that shows the number of votes associated with the photo?
I saw that there are several tables and several columns but I can't understand which one I should use to display the total number of votes.
Dear Julien,
The main votes table is #__competition_votes. Every record of this table is a vote.
To get the total votes for specific entry you can use CompetitionHelperSql::countEntryVotes() located in administrator/helpers/sql.php
/**
* SQL string to get entry votes count for use in SELECT statement.
*
* @param integer $entryIdKey Entry id key
* @param integer $valid Field 'valid' value: 0 or 1
* @param integer $score Field 'score' value: between 0 and 10
*
* @return string
*
* @since 1.8
* @throws InvalidArgumentException
*/
public static function countEntryVotes($entryIdKey, $valid = 1, $score = 0)
Kind regards,
Dmitrijs
So for each display of the number of votes, it must calculate all the votes that exist in the votes table and divide them by photo?
Doesn't this become a bit heavy in terms of resources?
Why not a simple vote column next to the information for each photo with the total votes for this photo which is done via incrementation?
I try to understand :)
Why not a simple vote column next to the information for each photo with the total votes for this photo which is done via incrementation?
Total votes is just a small part of voting :)
This table is needed to save the additional data of a vote, because there a lot of voting options that need to be supported and checked. Look in the component Options > Contest > Voting Options, Contest Voting Options, Entry Voting Options and Voting Check Options :)
So for each display of the number of votes, it must calculate all the votes that exist in the votes table and divide them by photo?
It depends on your situation. If you have a list of entries then this can be done with one query, no for every entry.
Kind regards,
Dmitrijs
I am creating a module to display slider images and I am looking for a way to display the number of votes as well as the message.
I followed your instructions but I'm completely lost.
Since to display the images in my slider I do not use the image ID but a URL which is constructed I cannot put the votes and messages in relation to the photo.
I imagined decomposing the name of the image in the url then removing the prefix which is med_.
Then check in the table and in the corresponding column if an image corresponds to the name.
If so, this retrieves the image ID.
Then you still have to display the message and the votes.
I'm a little lost, even a lot.
Before starting with your component I hardly ever coded and I learn quickly but now I'm really struggling.
Could you help me implement it concretely?
Would it be possible to have your carousel module which is no longer compatible so that I can look at its structure?
This should help me finalize what I'm doing.
Thank you very much 🤗
> and I am looking for a way to display the number of votes as well as the message
Do you mean a voting button that will allow to vote?
> Would it be possible to have your carousel module which is no longer compatible
Carousel module is completely out of date. It does not have voting.
I think you can look at Entries module. It has everything you need. Only the layout should be changed.
Kind regards,
Dmitrijs