メッセージ表示部のテンプレートを作成します。
基本的には、これまでと同じですがphpからクラスを渡す方法を見てみます。
以下にテンプレートを示します。
<html> <head> </head> <body> <a href="topic.php?fid={$foruminfo->fid}&pg={$foruminfo->pg}">{$forumname}</a><br> <table bgcolor=#FE9423 cellspacing=1 cellpadding=0> <tr><td> <table bgcolor=#FFFFFF cellspacing=0 cellpadding=0> <tr><td> <table width=700> <tr bgcolor=#7B9FB6> <td colspan=2 width=400>{$post->subject}</td> </tr> <tr bgcolor=#E7EFF0> <td width=500>{$post->user}</td><td align=right>{$post->post_date}</td> </tr> <tr bgcolor=#E7EFF0> <td colspan=2>{$post->message}<br><br><br></td> </tr> </table> </td></tr> </table> <table bgcolor=#FFFFFF cellspacing=0 cellpadding=0> <tr><td> <table width=700> {foreach item=postarray from=$postarray} <tr> <td width=400>{$postarray.level} <a href = "msg.php?fid={$foruminfo->fid}&tid={$foruminfo->tid}&pg={$foruminfo->pg}&pid={$postarray.post_id}"> {$postarray.post_subject}</a> </td> <td width=150>{$postarray.post_date}</td> <td>{$postarray.post_user}</td> </tr> {/foreach} </table> </td></tr> </table> </td></tr> </table> </body> </html>
ここでポイントになるのは、$postです。
$postはphp側でのクラスをアサインしています。
クラスのメンバ変数を参照するには、'->'の後にメンバ変数を指定することで参照できます。
Copyright 1997-2010 BBB All rights reserved.