The Poll extension for the Yii framework allows you to create custom polls for both anonymous and authenticated users to vote on.
- Basic Gii-created CRUD functionality
- Portlet to load on additional pages, which displays either the latest or a user-specified poll
- Polls can be either open or closed to voting
- IP restricted voting for anonymous users (enabled by default)
- Authenticated users can cancel their votes on open polls
- If IP restriction is enabled, you can also configure the ability for anonymous users to cancel their votes (disabled by default)
- Users must vote on a poll in order to see the results (enabled by default)
This has been tested with 1.1.8, but should work with any version.
You must also:
- Setup a User active record with an integer ID returned by Yii::app()->user->id.*
- 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)
*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:
To load a specific poll:
$this->widget('EPoll', array('poll_id' => 1));
February 9, 2012
- Duplicate widget submission bug fix
- Added ability to export poll results
- Rewrote URLs
October 18, 2011
- Bug fixes, renamed controllers to lowercase for URL mapping
- Moved configuration from app to module
October 17, 2011
- Initial release