- 论坛徽章:
- 0
|
phplib模板while内嵌循环失败问题求助
二级循环,请留意有注释的地方
$t = new Template();
$t->;set_file( "handle", "hierarchy.tpl" );
$plant = array( "vegetable", "fruit" );
$details = array( array( "cabbage", "radish" ), array( "apple", "orange" ) );
$t->;set_block( "handle", "cyc", "cyces" );
$t->;set_block( "cyc", "subCyc", "subCyces" ); // 第二层句柄为第一层的输出
foreach ( $plant as $k =>; $catName ) {
$t->;set_var( "subCyces" ); // 不可少的一句!
foreach( $details[$k] as $itemName ) {
$t->;set_var( "itemName", $itemName );
$t->;parse( "subCyces", "subCyc", true );
}
$t->;set_var( "catName", $catName );
$t->;parse( "cyces", "cyc", true );
}
$t->;pparse( "out", "handle" ); |
|