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