Q: Proper code how to display advanced poll from node?

Paintbox - November 26, 2008 - 13:48
Project:Advanced Poll
Version:5.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

I am working on integrating Advanced Poll, but extensive research of the Adv. Poll issues has proven fruitless into making it work.

I am using the following code I found here :
[code]
$node = node_load('114');
$node->teaser = $content;
unset($node->title);

print "Your vote:";
print node_view($node, $teasers, false, $links);
$output = theme('advpoll_results', check_plain($node->title), $results['results'], $results['votes'], $node->links, $node->nid, $node->voted, $node->cancel_vote);
[/code]

What happens with this code is that the vote doesn't get registered on certain computer figurations, they are thanked for the vote, but even after a refresh, the results do not show up. I am using version 5.x-1.x.-dev.

Before I do further debugging, I want to make sure I am using the preferred code to display a poll. Thanks for any help!

#1

ChrisKennedy - December 8, 2008 - 06:52
Status:active» postponed (maintainer needs more info)

I have no idea what you mean, please elaborate.

#2

Paintbox - December 10, 2008 - 10:37

Well, what I want to do is display a poll I made. I need the code for this. I grabbed the code I posted earlier from these threads but it doesn't work and I am sure I am doing something wrong.

I would be grateful if you could post the code you use to display an advanced poll. This may be code you use in a block, or code you can use in a say a node-frontpage.tpl file...

I hope I explained myself better this time, and thank you for any reply.

#3

mrrjpp - December 18, 2008 - 02:38

The issue with advpoll is that the way poll form is loaded isn't very useful outside of the normal drupal scope. What should happen is a new function added that handles loading up the poll form (css, js, and the form itself) that way it can be reused in not so typical scenarios.

Anyways, this should do what you need, but it's still not the ideal solution:

$poll = advpoll_view($node, FALSE, TRUE);
print $poll->content['poll']['#value'];

#4

Paintbox - December 18, 2008 - 10:01

Thank you very much for your reply, I will try this out ASAP. From what I understand it would be great if a function would be added for easy of use outside a node.

#5

kenorb - July 1, 2009 - 11:59

Maybe something like:

<?php
node_view
(node_load($node->nid), FALSE, TRUE);
?>

Where $node->nid is nid of node to load.

#6

PeterZ - July 23, 2009 - 13:40

I used this:

<div style="margin-left: auto; width: 240px; margin-right: auto">
<?php
 
print node_view(node_load(array('nid' => 436)), 1);
?>

</div>

Replace 436 with the nodeid of your poll. Make sure to use PHP code as your input format.

 
 

Drupal is a registered trademark of Dries Buytaert.