[ Index ] |
|
Code source de SugarCRM 5.0.0beta1 |
1 <? 2 3 /* 4 example 3 5 autoreset 6 7 8 9 */ 10 11 require "xtpl.p"; 12 13 $xtpl=new XTemplate ("ex3.xtpl"); 14 15 /* this is the code from example 2: */ 16 17 $rows[1]=array( /* add some data */ 18 ID=>"38", 19 NAME=>"cranx", 20 AGE=>"20" 21 ); 22 23 $rows[2]=array( /* add some data */ 24 ID=>"27", 25 NAME=>"ozsvar", 26 AGE=>"34" 27 ); 28 29 $rows[3]=array( /* add some data */ 30 ID=>"56", 31 NAME=>"alpi", 32 AGE=>"23" 33 ); 34 35 for ($i=1;$i<=3;$i++) { 36 $xtpl->assign("DATA",$rows[$i]); /* assign array data */ 37 $xtpl->assign("ROW_NR",$i); 38 $xtpl->parse("main.table.row"); /* parse a row */ 39 } 40 41 $xtpl->parse("main.table"); /* parse the table */ 42 43 /* now, if you wanted to parse the table once again with the old rows, 44 and put one more $xtpl->parse("main.table") line, it wouldn't do it 45 becuase the sub-blocks were resetted (normal operation) 46 to parse the same block two or more times without having the sub-blocks resetted, 47 you should use clear_autoreset(); 48 to switch back call set_autoreset(); 49 */ 50 51 $xtpl->clear_autoreset(); 52 for ($i=1;$i<=3;$i++) { 53 $xtpl->assign("DATA",$rows[$i]); /* assign array data */ 54 $xtpl->assign("ROW_NR",$i); 55 $xtpl->parse("main.table.row"); /* parse a row */ 56 } 57 58 $xtpl->parse("main.table"); /* parse the table */ 59 $xtpl->parse("main.table"); /* parse it one more time.. wihtout clearing the rows (sub-block reset) */ 60 61 $xtpl->parse("main"); 62 $xtpl->out("main"); 63 64 /* 65 66 Revision 1.1 2004/05/27 05:30:47 sugarjacob 67 Moving project to SourceForge. 68 69 Revision 1.1 2004/05/19 01:48:20 sugarcrm 70 Adding files with binary option as appropriate. 71 72 Revision 1.2 2001/03/26 23:25:02 cranx 73 added keyword expansion to be more clear 74 75 */ 76 77 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Sep 11 10:48:47 2007 | par Balluche grâce à PHPXref 0.7 |