We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11699
    • 11 Posts
    Hi all

    I am working with the polls module to create a poll option on my site. Currently it appears that this module wants to redirect to another page once the user votes.

    What I wish it to do is remain on the same page but display a results view instead.

    I have 2 chunks that seperatly display the poll and then the results.

    Is there a way in the template/chunk to look for a $_GET variable such as ’voted’ and based on its presence display either the poll or results view?

    i.e. it would work like this

    if(voted var == ’y’)
    display results view
    else
    display poll view


    Am fairly new to the workings of modx so any opinions/help would be appreciated

    Thanks in advance
      • 3749
      • 24,544 Posts
      A snippet at the top of the voting page is probably the best way. Something like this:

      <?php
      if (isset$_POST['voted'] && $_POST['voted']=='Yes')) {
        $modx->sendRedirect($modx->makeURL->(##));
      }
      ?>


      Replace ## with the ID of the results page.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting