Connect a binary poll with a CCK content type
frasketi - August 15, 2008 - 18:32
| Project: | Advanced Poll |
| Version: | 5.x-1.0-beta6 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I have a content type that tracks requests to distribute documents/information to researchers. I would like to be able to automatically create a simple Yes/No poll for each submission so that other members can vote on the requests approval.
Example, I create a new request #R100. I would like to have a poll automatically created with a question "Do you Approve of R100" Yes/No.
Perhaps I could put the poll in a block until the status field of the request changes from pending to approved/denied.
Any thoughts on how to accomplish this?
Thanks

#1
Coincidentally, I'm looking for the same functionality.
I.e. A new content type A being created, a new predefined poll will be tied to A as part of the 'content'.
CCK to the poll? A block should work also. Any idea?
#2
Here is how I did it, taken from node_factory
- install workflow_ng and token module
- create a workflow 'make child by parent' for event 'Content has been created'
- add a condition 'is parent' and select the 'parent' content type
- add an action 'create child' of type 'execute PHP code'
- add the following PHP code to the action. Note the usage of token constructs like [node:title] and without the
<?php ?><?php
// your poll choices
$choices = array(
array('label' => 'Yes'),
array('label' => 'No'),
);
// other advpoll settings
$settings = array(
'max_choices' => 1,
'algorithm' => 'plurality',
'show_votes' => 1,
);
$node = new StdClass();
$node->type = 'advpoll_binary';
$node->status = 1; // published
$node->title = "Do you Approve of " . [node:title];
$node->body = '';
$node->choices = $choices;
$node->settings = $settings;
// add this if using nodereference
$field_nodereference = array();
$field_nodereference['nids'] = [node:nid];
$node->field_nodereference = $field_nodereference;
// add this is using node relativity
$node->parent_node = $parent->nid;
node_submit($node);
node_save($node);
?>
#3
Automatically closed -- issue fixed for two weeks with no activity.