function poll_page in Drupal 4
Same name and namespace in other branches
- 5 modules/poll/poll.module \poll_page()
- 6 modules/poll/poll.pages.inc \poll_page()
- 7 modules/poll/poll.pages.inc \poll_page()
1 string reference to 'poll_page'
- poll_menu in modules/
poll.module - Implementation of hook_menu().
File
- modules/
poll.module, line 257 - Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_page() {
// List all polls
$sql = "SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC";
$sql = db_rewrite_sql($sql);
$result = pager_query($sql, 15);
$output = '<ul>';
while ($node = db_fetch_object($result)) {
$output .= '<li>' . l($node->title, "node/{$node->nid}") . ' - ' . format_plural($node->votes, '1 vote', '%count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
}
$output .= '</ul>';
$output .= theme("pager", NULL, 15);
return $output;
}