set_file("FileHandle", $template_file); $t->set_block("FileHandle", "pageblock", "pblock"); $t->set_block("FileHandle", "chapterblock", "cblock"); $page=1; for ($chapter=1; $chapter<=3; $chapter++) { $t->set_var("chapter_id", $chapter); $t->parse("cblock", "chapterblock", true); for ($page=$page; $page<=$chapter*3; $page++) { $t->set_var("page_id", $page); $t->parse("pblock", "pageblock", true); } } $t->parse("Output", "FileHandle", true); $t->p("Output"); ?>