The Poll extension for the Yii framework allows you to create custom polls for both anonymous and authenticated users to vote on.
Features include:
This has been tested with 1.1.8, but should work with any version.
You must also:
*An example of this type of setup is explained here: Building a Blog System using Yii
The next step is to install the database schema located in '/data/poll.sql', modifying the table prefixes as needed, as well as the foreign key constraint referencing the user's ID.
return array( ... 'import' => array( 'application.modules.poll.models.*', 'application.modules.poll.components.*', ), 'modules' => array( 'poll' => array( // Force users to vote before seeing results 'forceVote' => TRUE, // Restrict anonymous votes by IP address, // otherwise it's tied only to user_id 'ipRestrict' => TRUE, // Allow guests to cancel their votes // if ipRestrict is enabled 'allowGuestCancel' => FALSE, ), ), );
The Poll extension has the basic Gii-created CRUD functionality, as well as a portlet to load elsewhere.
To load the latest poll:
$this->widget('EPoll');
To load a specific poll:
$this->widget('EPoll', array('poll_id' => 1));
February 9, 2012
October 18, 2011
October 17, 2011
Total 10 comments
Thanks for your suggestion to include 'schemaCachingDuration' => 0, at db'=>array( .....
but it did not work
However, I deleted the braces at public function tableName() { return 'poll'; } and it works.
Now, I have another problem: I can see anything in my view at
<?php $this->widget('EPoll'); ?>I double checked all steps you mentioned but nothing is shown. Any suggestion? Thanks your help Best regards, Douglas
@Douglas Lopez You probably enabled database schema caching, in your config. To fix it, modify it so it refreshes the cache and then put it how it was
I am trying to implement the Poll extension in my application.
After creating the tables: poll, poll_choice and poll_vote (in postgres, after the corresponding conversion from mysql ), and include in config/main.php
'ext.poll.models.*', 'ext.poll.components.*',and .... 'modules'=>array( ...
'poll' => array( // Force users to vote before seeing results 'forceVote' => TRUE, // Restrict anonymous votes by IP address, // otherwise it's tied only to user_id 'ipRestrict' => TRUE, // Allow guests to cancel their votes // if ipRestrict is enabled 'allowGuestCancel' => FALSE, ),I did the generation of the corresponging models for these 3 tables. and after including, per your instruction, in my view, the following statement: <?php $this->widget('EPoll'); ?>
The system produced the following error:
Poll table "{{poll}}" defined in the active record class "Poll" can not be found in the data base. I did some sql statements by using pgadmin and tables looks good.
What Did I do wrong? Please your help is appreciated. Best regards, Douglas López
I also would like to know what you mean by:
"Add an anonymous user in the database with ID 0 (and either set the User ID to default to 0 in the database, or in your UserIdentity file)"
1) If you cant create a poll try:
2) If you get:
:D
Good work. But What have you tried to say by:
Please help. I am in problem.
No man, WE WANT THIS NOW :)
That is a good call on the configuration, I'll update the code and also put up a demo on my server when I get a minute.
Hi... if you could add some picture of the poll...
Or create demo at some free hosting...
Looks nice but why would you put configuration in the app params and not directly in the module configuration?
Leave a comment
Please login to leave your comment.