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);
}
CommentFileSizeAuthor
poll-patch.txt727 bytesbjaspan

Comments

bjaspan’s picture

Category: feature » bug

I 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.

Gary Feldman’s picture

Version: x.y.z » 4.7.4

+1

I just ran into this, and it's an annoying problem.

killes@www.drop.org’s picture

Version: 4.7.4 » 6.x-dev
Category: bug » feature

looks like a feature request to me.

bdragon’s picture

Status: Needs review » Needs work

This 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

catch’s picture

Version: 6.x-dev » 7.x-dev

Bumping up a version.

Jaza’s picture

Status: Needs work » Closed (fixed)

$form['#node'] is now populated with the node object in poll_view_voting(). This can then be accessed in the preprocess function or in the template for poll_vote.

So I'd say the change in this patch has now been implemented. Closing.