I think assign_block_vars are for repeating records of a query of data.
For example if I want all questions based on course and creatdby:
$result = $db->sql_query("SELECT * FROM ".QUESTIONS_TABLE." q
JOIN ".COURSE_TABLE." c ON (q.course_id = c.course_id)
JOIN ".USERS_TABLE." u ON (u.user_id = q.createdby)
WHERE q.course_id = ".$course_id." AND q.createdby = ".$user_id."");
I then assign the values:
$template->assign_block_vars('question',array(
'qid' => $question['question_id'],
'NAME' => $question['ques_name'],
'STEM' => nl2br($question['stem'])."<br>",
'MEDIA' => $media."<br>",
'FEED' => $question['feedback']."<br>"));
$ca = $question['cat_id'];
switch ($question['qtype']) {
case MULTIPLECHOICE :
{
$letters = array("A.","B.","C.","D.","E.", "F.");
$points = explode ("#", $question['points'] );
for ( $z = 0; $z < 6; $z++) {
if (!empty($question['choice'.($z+1)])) {
$ques_options =$question['choice'.($z+1)].' <span class="helptext">('.$points[$z]." point ) </span>";
$template->assign_block_vars('question.options',array( 'ATTRIBUTES' => $ques_options, 'OPTION_ID' => $letters[$z] ));
}
}
break;
} // eof switch
Then output the page.
$template->pparse('body');
It's just that I am not getting any output other than an empty template.
<table width="100%" cellpadding="0" cellspacing="0" border="1" class="bodyline">
<tr>
<td height="140" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<!-- BEGIN user -->
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="borderline" align="center">
<tr>
<td align="left" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="bodyline">
<tr>
<td height="240" valign="top">
<!-- BEGIN question -->
<form name="" action="" method="post">
<table cellpadding="3" cellspacing="0" border="0" width="98%" align="center">
<tr>
<td width="20"> </td>
<td>{question.NAME}</td>
</tr>
<tr><td colspan="2" class="gen">{question.STEM}<p></p>{question.MEDIA}</td></tr>
<!-- BEGIN options -->
<tr>
<td class="gen" align="center">{question.options.OPTION_ID}</td>
<td class="gen">{question.options.ATTRIBUTES}</td>
</tr>
<!-- END options -->
</table>
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="bodyline">
<tr>
<td align="left"> </td>
<td align="left"> </td>
</tr>
<tr><td class="gen">Feedback:<br><br>{question.FEED}</td></tr>
</table>
</form>
<!-- END question -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
</table>