Mini Tutorial: How to Display the Magento Poll Voting Form and Results

By default, the Magento Voting Poll is displayed whenever the 2 Columns with the right bar layout are used. To call the Magento Poll voting form from the WYSIWYG editor, follow these steps:

1. Add the following php code on top of base/poll/active.phtml:

$action = Mage::getBaseUrl().’poll/vote/add/poll_id/’.$this->getPollId();
$poll = Mage::getModel('poll/poll')->load($this->getPollId());
$poll_answers = Mage::getResourceModel('poll/poll_answer_collection')->addPollFilter($this->getPollId())->getItems();

2. In the WYSIWYG editor of a static block or CMS page add:

(You can get the Poll ID from the admin in CMS > Polls and set it as poll_id)

{{block type="poll/poll" template="poll/active.phtml" poll_id="1"}}

To display the Magento Poll results:

1. Do step 1 above to base/poll/result.phtml

2. Do step 2 above but replace “active.phtml” to “result.phtml”