We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    I created a little user feedback form using the polls package - it worked when I was calling it directly from the page but when I placed it into a template the poll would not show up with a 'division by zero' error in the modx logs.

    Here's what I did:

    - I created a TV called FeedbackID to hold the category ID of the poll I wanted to show

    - I added this to my template:
    [[!If? 
         &subject=`[[*FeedbackID]]` 
         &operator=`!=` 
         &operand=`0` 
         &then=`[[$ShowFeedback]]` 
    ]]
    


    - I created the ShowFeedback chunk:
    [[*FeedbackID]]
    [[!PollsLatest? 
         &category=`[[*FeedbackID]]` 
         &tplVote=`feedbackPollOuterTpl` 
         &tplVoteAnswer=`feedbackPollAnswerTpl` 
         &tplResult=`feedbackResultOuterTpl` 
         &tplResultAnswer=`feedbackPollResultAnswerTpl`
    ]]
    


    The poll does not show up, the FeedbackID is displayed correctly, but no poll.

    I can get the poll to display if I place this in the content of the page I want to see the poll on:
    [[!PollsLatest? 
         &category=`[[*FeedbackID]]` 
         &tplVote=`feedbackPollOuterTpl` 
         &tplVoteAnswer=`feedbackPollAnswerTpl` 
         &tplResult=`feedbackResultOuterTpl` 
         &tplResultAnswer=`feedbackPollResultAnswerTpl`
    ]]
    



    I even tried to pass the FeedbackID to the chunk like this:
    [[!If? 
         &subject=`[[*FeedbackID]]` 
         &operator=`!=`
         &operand=`0` 
         &then=`[[$ShowFeedback? &fid=`[[*FeedbackID]]`]]` 
    ]]
    
    // ShowFeedback chunk ----- 
    [[*fid]]
    [[!PollsLatest? 
         &category=`[[*fid]]` 
         &tplVote=`feedbackPollOuterTpl` 
         &tplVoteAnswer=`feedbackPollAnswerTpl` 
         &tplResult=`feedbackResultOuterTpl` 
         &tplResultAnswer=`feedbackPollResultAnswerTpl`
    ]]
    
    


    Which does show the fid, but not the poll..

    Extremely frustrated now, any ideas on how to fix this?

    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 23510
      • 168 Posts
      If you hardcode a value for feedbackID e.g.

      [[$ShowFeedback? &fid=`10`]]


      will that work on a page on its own?
        • 26503
        • 620 Posts
        [[$ShowFeedback? &fid=`10`]]
        


        Does work on a page of it's own...
        This is the full error I get:
        (ERROR @ /var/www/vhosts/oncologyeducation.com/httpdocs/core/components/polls/model/polls/modpollanswer.class.php : 12) PHP warning: Division by zero
        
        [ed. note: sean69 last edited this post 14 years, 8 months ago.]
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 26503
          • 620 Posts
          this has got something to do with the If, it works fine if I use an output filter instead:

          
          [[*FeedbackID:notequalto=`0`:then=`[[$ShowPollFeedback]]`]]
          
          


          not the first time 'If' has given me problems....

          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525
            • 23510
            • 168 Posts
            I vaguely remember IF not working for me at some point. Also there are times when the output filter does not work properly and I have to use IF.