.php extension.
<?php
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/poll_cookie.php";
?>
<?php
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/booth.php";
echo $php_poll->poll_process(ID#);
?>
That will display the poll specified by ID# with the "default" template set, and handle everything for you.. it looks like this:
| joe-kanakaraj.com | ||||||||||||||||||
|
poll_process line:
# set the max width for the bar graphs in the results page.
# set the max height for the bar graphs in the results page.
# use a different template (e.g. "simple" "plain" "popup")... you can make your own in the admin area!
$php_poll->set_template_set("graphic");
$php_poll->set_max_bar_length(80);
$php_poll->set_max_bar_height(10);
You could also use these commands instead of (or in addition to) the poll_process one if you want:
# just show the poll question text.
# just print the results.
echo $php_poll->view_poll_result(ID#);
echo $php_poll->get_poll_question(ID#);
<?php
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/booth.php"; # don't use this again if you already have it on the page somewhere.
$php_poll->set_template("poll_list"); # required to switch to poll list mode!
$php_poll->set_polls_per_page(5); # maximum polls to show per page.
$php_poll->set_date_format("m/d/Y"); # how to display the time stamp on polls.
echo $php_poll->view_poll_list(); # displays the poll list.
echo $php_poll->get_list_pages(); # displays the "next page","last page" thing when you have lots of polls.
?>
Here's what all that will actualy look like (with polls_per_page set to 2):
| 06/08/2007 | Who has gain the most weight since college |
| 06/08/2007 | What is your favourite scripting language? |
Note, these links just link to the current page with poll_id set to something!
If you want it to actually show the poll, you're going to have to put this code like this in the same page:
<?php
if ($poll_id) { # only show the poll after we've clicked a link!
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/booth.php"; # don't use this again if you already have it on the page somewhere.
echo $php_poll->poll_process($poll_id); # Actually do use "$poll_id" there..
}
?>
You can also edit the "poll_list" template in the admin area to point to a different page with that code.
Here's an example of what that code will show (please click a poll in the list above):
process_poll command. However, the comments will not be displayed
anywhere (besides in the admin area), unless you add some more PHP code:
<?php
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/booth.php"; # don't use this again if you already have it on the page somewhere.
$php_poll->set_template("poll_comment"); # required to switch to comment mode!
$php_poll->set_comments_per_page(5); # maximum comments to show per page.
$php_poll->set_date_format("d/m/Y H:i"); # how to display the time stamp on comments.
$php_poll->data_order_by("time","desc"); # how to sort the comments. (show oldest first with ("time","asc"))
echo $php_poll->view_poll_comments(ID#); # displays the comments for poll ID#.
echo $php_poll->get_comment_pages(ID#); # displays "next page","last page" thing when you have lots of comments.
?>
Here's what all that will actualy look like (with comments_per_page set to 2):
| nobody
nobody@server.com
- 08/06/2007 08:47 localhost - Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0) |
| This is the first comment! |
<?php
include_once "/home/jkanakaraj/joe-kanakaraj.com/polls/booth.php"; # don't use this again if you already have it on the page somewhere.
$php_poll->set_template("poll_form"); # required to switch to comment form mode!
$php_poll->set_form_error(array( # set which fields are required and what errors to give if blank.
"name" => "Please enter your name.",
// "email" => "You must specify your e-mail address.", # uncomment this to require an email address.
"message" => "You must specify a message."
));
echo $php_poll->comment_process(ID#); #displays the form.
?>
Here's what all that will actually look like: