We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26115
    • 15 Posts
    I need to show only one poll snippet at time:

    <?php
    $a = "[!pollsvote? &pollid=`1` &redirect=`1` &onevote=true &resultsbutton=true!]";
    $b = "[!pollsresults? &pollid=`1` &decimal=`0`!]";
    if ($onevote ==’true’){
    return $a;
    } else {
    return $b;
    } ?>
    ?>

    how is possible to implement this code in modex? I need to show only one snippet bassed on onevote.

    Thank you for your dedicated time

      • 22303 MODX Staff
      • 10,725 Posts
      Use the $modx->runSnippet() method.

      e.g.
      <?php
      $output= '';
      if ($onevote == 'true') {
          $output.= $modx->runSnippet('pollsvote', array(
              'pollid' => '1',
              'redirect' => '1',
              'onevote' => 'true',
              'resultsbutton' => 'true'
          ));
      } else {
          $output.= $modx->runSnippet('pollsresults', array(
              'pollid' => '1',
              'decimal' => '0'
          ));
      }
      return $output;
      ?>
        • 26115
        • 15 Posts
        Thank you, your solution works fine smiley