function poll_page in Drupal 5
Same name and namespace in other branches
- 4 modules/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/ poll.module - Implementation of hook_menu().
File
- modules/
poll/ poll.module, line 329 - Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_page() {
// List all polls.
$sql = db_rewrite_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 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC");
// Count all polls for the pager.
$count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1');
$result = pager_query($sql, 15, 0, $count_sql);
$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;
}