Skip to main content

#101 Table and column of votes in the database

Posted in ‘NorrCompetition’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information (available for public)

PHP version
7.4

Latest post by b2z on Thursday, 21 March 2024 10:48 EET

webquality

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.

b2z

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

webquality

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 :)

b2z

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

webquality

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?

 

 

webquality

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 🤗

b2z

> 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

Support information

Support hours: You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+3), but not limited. Our staff is pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days.


Our time: / Your time:

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. We also ask you to remove temporary credentials at your site after the problem is resolved. Thank you.

Support of free extensions is not provided on this forum. Please submit your questions or report issues via Github tracker. See link on the product page.