Jul 05, 2009, 09:34 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1] 2 3 ... 5   Go Down
  Print  
Author Topic: [Module/Snippet] Polls Module and Snippets  (Read 23165 times)
0 Members and 1 Guest are viewing this topic.
garryn
Coding Team
*
Posts: 1,252



WWW
« on: Jan 25, 2006, 07:28 PM »

Hi all,

This is the first module/snippets I've written so thought I'd start off simple! Smiley (I can't take credit for all the code, I picked up a thread on the Etomite forum and decided to finish it off)

Version 3 of the Poll Module/Snippets is now available.

For those who are upgrading from version 2 and didn't experience any problems with the install, please just update your voting snippet.

Demo URL: http://www.immerse.me.uk/index.php?id=4

Installation and Setup guide:

1) Download and extract the PollModule.zip file.
2) Create a new module and insert the text from pollmanager_module.txt.
3) Important: Run the module now. This will install/update the database tables.
5) Create two new snippets and insert the text from the pollresults_snippet and pollvote_snippet text file into them.
6) Add the poll.css to your existing stylesheet (or any other way you choose to include it on your page) - you can edit the CSS to suit your needs.

Usage:
The Poll Manager Module allows for polls to be created/updated/deleted. The two snippets allow for the results and voting to be added to your site.

Example Snippet Usage:

Please ensure that if you set a redirect page that the page is published. Thanks jwtyler for catching this

The following would display the results of the poll with id=1 and rounded percentages:
Code:
[!pollresults? &pollid=`1` &decimal=`0`!]
To display the voting options for the same poll and redirecting to the document with id=1 (eg. use this option to redirect to a results page) with cookie logging enabled:
Code:
[!pollvote? &pollid=`1` &redirect=`1` &onevote=true &ovmessage=`You can only vote once` &resultsbutton=true!]
Changes

Version 3:

1. Results Button now shows when the parameter is set.
2. Corrected a minor problem in the $onevote code.
3. $ovmessage will now work when parameter is set - before, it would always use the default message.
4. Adjusted the SQL in the module so should work on 3.23* MySQL installs.
5. Some implementations may not have parsed the 'action' of the voting form correctly - this now uses a placeholder so shouldn't cause any issues from now on.

Have fun, Garry

MOD NOTE: Zip removed. Now in Repository:
http://modxcms.com/Polls-Module-526.html

Stats for posterity:
PollModule_v3.zip (7.59 KB - downloaded 295 times.)
« Last Edit: Aug 15, 2006, 10:22 AM by PaulGregory » Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #1 on: Jan 25, 2006, 07:58 PM »

Thanks! Exactly what I needed! Installing right now.
Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #2 on: Jan 25, 2006, 08:08 PM »

Garry, looks like your missing the choices table/field!
Logged

garryn
Coding Team
*
Posts: 1,252



WWW
« Reply #3 on: Jan 25, 2006, 08:22 PM »

Hi Mark,

Is it giving an error?

I've just noticed that it returns an error if you don't add the poll first before you click 'Add Choices'.

Once you've added your poll in the module, there's a button for 'Add Choices' - that should take you to another screen for adding choices to the poll.

EDIT: Add poll -> Click 'Edit' for that poll -> 'Add Choices'

I think the error checking has gone awry somewhere, I'll get a fix out soon as I can.


Thanks, Garry

 
« Last Edit: Jan 25, 2006, 08:26 PM by garryn » Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #4 on: Jan 25, 2006, 08:30 PM »

Getting this error:

« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - Unknown column 'choice' in 'field list' »
      SQL: INSERT INTO `ecrsoccer_com_-_site`.modx_poll_choices (pollid,choice) VALUES ('1',' adfs')
      [Copy SQL to ClipBoard]
 
Parser timing
  MySQL:    0.0001 s s   (0 Requests)
  PHP:    1138242584.3104 s s   
  Total:    1138242584.3105 s s
Logged

garryn
Coding Team
*
Posts: 1,252



WWW
« Reply #5 on: Jan 25, 2006, 08:36 PM »

Hi Mark,

Oops! You were right, the poll.sql file was missing a rather important field!! Shocked

I've uploaded a new zip in the first post, the only change is the sql file so if you drop your tables and then rerun the SQL, that should rectify the problem.

Cheers, Garry
Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #6 on: Jan 25, 2006, 09:11 PM »

In the pollvote snippet $PHP_SELF is never defined.
Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #7 on: Jan 25, 2006, 09:18 PM »

Also, you need to add $output = ""; before you can add to it via $output .= "blah";
Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #8 on: Jan 25, 2006, 09:40 PM »

Hrm.... when running the two snippets it ONLY shows my first 2 choices nomatter how many I have...
Logged

garryn
Coding Team
*
Posts: 1,252



WWW
« Reply #9 on: Jan 25, 2006, 10:04 PM »

Thanks for the pointers.

I'll have a proper crawl over all the code tomorrow and get a new version uploaded. I need to reassess the way I'm counting records returned via the modX->db->select() as I don't think my way is working!

Bye for now, Garry
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #10 on: Jan 25, 2006, 10:22 PM »

I'll have a proper crawl over all the code tomorrow and get a new version uploaded. I need to reassess the way I'm counting records returned via the modX->db->select() as I don't think my way is working!

Gary, instead of...
Code:
  $rs = $modx->db->select("*",$polltable,$where,"id ASC","");
  $limit = count($rs);
  if($limit > 0){
    $fields = $modx->db->getRow($rs);
  }
try something like...
Code:
  $rs = $modx->db->select("*",$polltable,$where,"id ASC","");
  $limit = $modx->db->getRecordCount($rs);
  if($limit > 0){
    $fields = $modx->db->getRow($rs);
  }
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
garryn
Coding Team
*
Posts: 1,252



WWW
« Reply #11 on: Jan 25, 2006, 10:57 PM »

Thanks Jason, just what I was looking for! I'll include that in my next update. Smiley
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #12 on: Jan 25, 2006, 11:31 PM »

Garryn, nice snippet/module. Thinking to make this template based snippet? So that we can expand the templating, which I believe will be a great addition to the new version. Keep it up Wink
Logged

banzai
Testers
*
Posts: 870


MODx Italia


WWW
« Reply #13 on: Jan 26, 2006, 04:12 AM »

Oh yes!! really needed snippet for community sites! Thanks for sharing!! Wink
Logged

MODx Websites Showcase 
Add your site to www.modx.it!
-----------------------------------------------------
FREE MODx Templates
www.tattoocms.it
-----------------------------------------------------
VIDEO: whats new in MODx 0.9.5   | VIDEO: MODx PHP Application Framework  |  modx Revolution  

bubuna.com - Web & Multimedia Design
davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #14 on: Jan 26, 2006, 06:31 AM »

* 26/01/06: New zip uploaded containing bug fixes for both snippets relating to the display of choices.

Cool, I'll have a use for it soon, really nice having this module !
I'll go and test it Smiley

Thanks !
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
Pages: [1] 2 3 ... 5   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!