Some sites wants to display poll links (results, older polls, comments) on the poll voting form even if the user hasn't voted yet. This can easily be accomplished via theme_poll_view_voting but only if the $node object is available since that is where the links are set.
The attached one-line patch provides the necessary info.
If this patch is committed, the following template.php snippet for displaying the poll results in the form could be posted:
function MYTHEME_poll_view_voting($form) {
if (is_array($form['node']['#value']->links)) {
$form['links'] = array
('#type' => 'markup',
'#value' => ('<div class="links">'.
theme('links', $form['node']['#value']->links).
'</div>'),
);
}
return theme_poll_view_voting($form);
}
| Comment | File | Size | Author |
|---|---|---|---|
| poll-patch.txt | 727 bytes | bjaspan |
Comments
Comment #1
bjaspan commentedI got confused for a moment thinking that this patch wasn't necessary because the poll's nid is available in the form passed to theme('poll_view_voting'). I'm submitting this followup to clarify why it is necessary.
The poll's links aren't saved in the database; they are dynamically created by poll_view(). So just passing the nid to the theme function isn't enough; the theme function needs the $node object containing the filled in ->links field.
Comment #2
Gary Feldman commented+1
I just ran into this, and it's an annoying problem.
Comment #3
killes@www.drop.org commentedlooks like a feature request to me.
Comment #4
bdragon commentedThis looks like it was rolled against a HEAD from before modules got their own directories...
|--- modules/poll.module 5 Oct 2006 11:29:35 -0000 1.195.2.2
|+++ modules/poll.module 9 Oct 2006 16:06:03 -0000
Comment #5
catchBumping up a version.
Comment #6
Jaza commented$form['#node']is now populated with the node object inpoll_view_voting(). This can then be accessed in the preprocess function or in the template forpoll_vote.So I'd say the change in this patch has now been implemented. Closing.