How do I call a specific poll as content into the sideblock. Currently only the last poll can be displayed in a predefined sideblock. Being able to call a poll of your own choise, would be very usefull.

If for example you have written a node about the pros and cons of a EU constitution, it would be very usefull to have a sideblock with a poll for 'yes' or 'no' to the constitution. Currently this is only possible if such a poll just happens to be the last poll you have made.

If you have many different node about different subject, it would be usefull to be able to connect these nodes with relevant polls in the sideblock.

Is there any way to call a specific poll via PHP? If yes, it would be easy, to do what I want, with the help of the side_content.module.

Best Regards
Lennart

Comments

raebee@drupal.org’s picture

First I created a poll in the usual way - via administer/create content. My poll ended up as node/50.

Then I created a custom block. Type is PHP and the code was as follows:

<?php
  $poll = node_load(array('nid'=>'50')); 
  poll_view($poll,1,0,1);
  echo "<strong>POLL</strong>";
  echo $poll->body;
  echo '</div>';
?>

I used url alias to tell the sytem which pages this block should appear on.

Hope that helps.

lennart’s picture

This is very useful!

Best regards,
Lennart

Best regards,
Lennart

dublin drupaller’s picture

Hi Raebee,

that's a handy little snippet that I think others would be interested in.

Can you create a handbook page for it under the following handbook pages:

Example custom blocks handbook page

and if you have the time:

sliced bread: php snippets handbook page

(scroll to the bottom of the hanbook page and click on ADD CHILD PAGE to add your snippet)

The only thing I would suggest adding in is a variable that makes it easier for non-php users to specify a different poll, i.e.

$pollid = '50';
$poll = node_load(array('nid' =>$pollid));

if you have the time..

cheers.

dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate