Displays results of poll instead of questions to those who can't vote

Sansui - June 20, 2008 - 15:47
Project:Advanced Poll
Version:5.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a set of polls that site members can vote on, and the poll needs to stay open indefinitely, but I want anonymous viewers to be able to see the results. Currently with printing out my nodes on my polls page, all the anonymous viewer gets are the questions + "Login to vote". How do I create a page just for results, or configure it so that anonymous sees results?

Currently I'm just doing this to display a series of polls in succession on one page

<?php
$node
= node_load('123');
print
node_view($node, $teasers, false, $links);
?>

#1

Sansui - June 20, 2008 - 18:47

I found a patch here -> http://drupal.org/node/272637 that adds an option for the display of poll results. It worked great for me, and an anonymous user can click the results tab to see the results.

What I would really like, though, is to be able to display the result tab directly. Is this something that can be done fairly easily with the node_load and view functions? I'm not well versed in what can be done with them, so I appreciate the hand holding :P

#2

Sansui - June 22, 2008 - 18:11

No ideas out there for displaying the result tab directly instead of the questions? :(

#3

Sansui - June 23, 2008 - 21:50

Is there any way to use this function advpoll_view_results($node,$teaser,$page) to view results directly?

#4

Sansui - June 23, 2008 - 22:06

For anyone else that might have been trying to do this, I mucked about enough that this kinda works, where 123 is the node that I want to display. So now I can just embed the results directly into the page for an ongoing poll that anonymous can't vote on.

<?php
  $node
= node_load('123');
 
$mode = _advpoll_get_mode($node->type);
  if (
_advpoll_can_view_results($node)) {
    if (
function_exists('advpoll_view_results_'. $mode)) {
     
$results = call_user_func('advpoll_view_results_'. $mode, $node, $teaser, $page);
     
$output = theme('advpoll_results', check_plain($node->title), $results['results'], $results['votes'], $node->links, $node->nid, $node->voted, $node->cancel_vote);
    }
  }
print
$output;
?>

 
 

Drupal is a registered trademark of Dries Buytaert.