We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9722
    • 11 Posts
    [!pollresults? &pollid=`1` &decimal=`0`!]


    That is what I have on the poll results page which is uncached.
      • 10313
      • 375 Posts
      @fireman:

      I’m not sure if i completely understand you. Can you view the poll results by looking at the preview of your results page from within the manager? If so, please check this:

      On your polling page in the frontend, after you voted for one option, can it be that below the "vote" button there is a message that you can only vote once? Because this is what I just found on my site.

      I call the pollvotes by
      [!pollvote? &pollid=`1` &redirect=`37` &onevote=false &ovmessage=`Sie können nur eine Stimme abgeben`!]


      And I found that &onevote will automatically be set to "true" whenever it gets any value assigned to it. Even if the value is "false". So you/we/I have to omit that parameter completely to let the user vote more than once and then the voter will be directed to the results page.

      Hope that helps
      Martin
        • 10226
        • 412 Posts
        Is there a working demo that is still live anywhere? I looked and looked.. no luck, is there something better?

        Does this work with 0.96?

        Thanks!
          • 29181
          • 480 Posts
          I just installed this.
          It works well but needed some pottering with for my needs.

          Basically my client wants to be able to use this in a restricted area for polls above and beyond the normal "What type of soup is your favourite" i.e. as a portal to allow nationwide members to vote for a committee etc.

          My simple solution was to remove the IP address bit of the code and replace it with the user instead. This was simple, and to avoid breaking anything the table is still named as it was by the original author.

          So basically

          		$useraddy = userIP();
          		$results = $modx->db->select('*', $iptable, 'ipaddress=\'' . $useraddy . '\' AND pollid=' . $_POST['poll_pollid'], '');


          has been replaced with

          	if ($useip == true) {
          		$results = $modx->db->select('*', $iptable, 'ipaddress=\'' . $theUser . '\' AND pollid=' . $_POST['poll_pollid'], '');


          which required that I added a new variable after the comment //setup initial variables

          $currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID());
          $theUser = $currentWebUser['username'];


          Beyonds as how I had gone this far...I replaced the default $ovmessage to

          $ovmessage = (isset ($ovmessage)) ? $ovmessage : 'A vote has already been submitted by '.$theUser.' for this poll.<br />If you think this is incorrect please contact <a href="[~106~]">the administrators</a>';
          


          I also found having a vote button a little odd...if I’m not allowed to vote anyway so I moved the if statement that checks if $novote isset from line 143

          One point that I have not mentioned is that the polls is restricted anyway. i have added no functionality to test that in the pollvote snippet.

          Hope this saves someone a couple of minutes sometime.

          @fruitwerks My example seems to be working but is in a restricted area. Do you just want to take a look or are you having problems?

          Thanks to the author for saving me a long long time setting this up!

          All the best,
          Taff
            Adrian Lawley: www.adrianlawley.com
            • 16866
            • 1 Posts
            Is there any way to have [[pollvote]] display [[pollresults]] if the user has already voted? I set onevote to true but this doesn’t appear to do what I want.

            Thanks for any help!

            edit: nevermind, here is a patch that does what I wanted..
            --- untitled
            +++ (clipboard)
            @@ -50,7 +51,12 @@
             
             //-- if 'Results' button has been selected
             if (isset ($_POST['results'])) {
            -	$modx->sendRedirect($url);
            +	return $modx->runSnippet('pollresults',array('pollid' => $pollid));
            +	//$modx->sendRedirect($url);
            +}
            +
            +if (isset($_COOKIE['poll' . $pollid])) {
            +	return $modx->runSnippet('pollresults',array('pollid' => $pollid));
             }
             
             //-- if vote was submitted increment polls and poll_choices vote counts
            
              • 10226
              • 412 Posts
              Does anyone have this live anywhere? Is there something better? I know this is somewhat old sad


              Thanks
                • 29181
                • 480 Posts
                I have it live, but only in a secure access area. sad I recommend installing it to try it out, it only takes about 10 minutes, but if you want, we could try and set you up a one-use account so you could see it in use, and maybe even the backend.

                Taff
                  Adrian Lawley: www.adrianlawley.com
                  • 10226
                  • 412 Posts
                  Well I bothered to install - I ran into an issue mentioned earlier. It had to do with the weblogin - which I do not use. The fix was to remove the redirect statement, probably won’t use that either.

                  What is the best way to display a random poll?

                  Thanks!
                    • 29181
                    • 480 Posts
                    I don’t think there is a way built in, when it comes to displaying a random poll. You could make a snippet to do it for you though by querying the ids in {prefix}polls and then randomly grabbing one and returning the result into your poll call, along the lines of
                    [!pollresults? &pollid=`[[OutputFromQuerySnippet]]` &decimal=`0`!]
                      Adrian Lawley: www.adrianlawley.com
                      • 15152
                      • 360 Posts
                      Has anyone been able to get this up and running properly (on a live site). In particular, have you been able to style the poll? I have torn the thing apart and completely re-done the style sheet but it doesen’t seem to have a lot of effect.

                      (The example page is not active.)

                      Thanks for any help.
                        There are no boring projects. Only boring executions. ~ Etzkorn
                        www.impress-design.com