HTML and CSS Reference
In-Depth Information
Adding the Vote Up Form View
The view for the vote up form keeps it pretty simple. Create a new file in system/views/ called question-vote.inc.php
and add the following markup:
<form method="post" class="vote"
action=" <?php echo $form_action; ?> ">
<input value="I also have this question."
type="submit" <?php echo $disabled; ?> />
<input type="hidden" name="question_id"
value=" <?php echo $question_id; ?> " />
<input type="hidden" name="room_id"
value=" <?php echo $room_id; ?> " />
<input type="hidden" name="nonce"
value=" <?php echo $nonce; ?> " />
</form>
This markup uses the variables set in output_vote_form() to dynamically generate the button that allows
attendees to submit a vote for a question.
Loading the Answer Form
Very similar to the vote up form, you now need to add a method to load the answer form, which allows the presenter
to mark a question answered. Add the following code to the Question class:
public function output_view( )
{
$questions = $this->get_questions();
$output = NULL;
foreach ($questions as $question) {
/*
* Questions have their own view type, so this section initializes
* and sets up variables for the question view
*/
$view = new View('question');
$view->question = $question->question;
$view->room_id = $this->room_id;
$view->question_id = $question->question_id;
$view->vote_count = $question->vote_count;
if ($question->is_answered==1) {
$view->answered_class = 'answered';
} else {
$view->answered_class = NULL;
}
// Checks if the user has already voted up this question
$cookie = 'voted_for_' . $question->question_id;
if (isset($_COOKIE[$cookie]) && $_COOKIE[$cookie]==1) {
$view->voted_class = 'voted';
 
Search WWH ::




Custom Search