We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10487 MODX Staff
    • 1,535 Posts
    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:
    [!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:
    [!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.)
      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 18397
      • 3,250 Posts
      Thanks! Exactly what I needed! Installing right now.
        • 18397
        • 3,250 Posts
        Garry, looks like your missing the choices table/field!
          • 10487 MODX Staff
          • 1,535 Posts
          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

            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 18397
            • 3,250 Posts
            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
              • 10487 MODX Staff
              • 1,535 Posts
              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
                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com
                • 18397
                • 3,250 Posts
                In the pollvote snippet $PHP_SELF is never defined.
                  • 18397
                  • 3,250 Posts
                  Also, you need to add $output = ""; before you can add to it via $output .= "blah";
                    • 18397
                    • 3,250 Posts
                    Hrm.... when running the two snippets it ONLY shows my first 2 choices nomatter how many I have...
                      • 10487 MODX Staff
                      • 1,535 Posts
                      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
                        Garry Nutting
                        Senior Developer
                        MODX, LLC

                        Email: [email protected]
                        Twitter: @garryn
                        Web: modx.com

                      This discussion is closed to further replies. Keep calm and carry on.