HTML and CSS Reference
// TODO: Check if the user has already voted up the question
$view->voted_class = NULL;
// TODO: Load the vote up form for attendees, but not presenters
$view->vote_link = '';
// TODO: Load the answer form for presenters, but not attendees
$view->answer_link = '';
// Returns the output of render() instead of printing it
$output .= $view->render(FALSE);
This method isn't complete yet, but the building blocks are in place to start looking at how the view will shape up.
The constructor fires the main Controller constructor and then checks for a valid room ID, throwing an error if
none was passed in the URI.
Because a question will never be displayed on its own—meaning outside the context of a room—the get_title()
method simply returns NULL . Remember that it does need to be declared because it's part of the abstract parent class.
The output_view() method loads all questions for the room using the get_questions() method, which you'll
define a bit later. It then loops through each question, loading the question view and populating it with the individual
question's data. Some of the variables need to be updated; each of them has been marked with a TODO comment, so
it'll be easy to spot them later, when it's time to come back and write those bits.
Adding the Question View
The view for the question app doesn't look like much; it's just a snippet of the HTML you wrote back in chapter 7.
However, it's got a lot of variables.
Create a new file called question.inc.php and store it in system/views/ . Inside, add the following:
<li id="question- <?php echo $question_id; ?> "
data-count=" <?php echo $vote_count; ?> "
class=" <?php echo $voted_class, ' ', $answered_class; ?> ">
<?php echo $answer_link; ?>
<?php echo $question; ?>
<?php echo $vote_link; ?>
</li><!--/#question- <?php echo $question_id; ?> -->
This markup spits out the variables set in output_view() , shown previously. At the moment, this view wouldn't
look like much because $voted_class , $voted_link , and $answer_link are all NULL or empty.