[ Index ]
 

Code source de SugarCRM 5.0.0beta1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/XTemplate/ -> ex2.php (source)

   1  <?
   2  
   3      /* 

   4          example 2

   5          demonstrates multiple level dynamic blocks

   6  

   7  

   8  

   9      */
  10  
  11      require "xtpl.p";
  12  
  13      $xtpl=new XTemplate ("ex2.xtpl");
  14  
  15      /* you can reference to array keys in the template file the following way:

  16          {DATA.ID} or {DATA.NAME} 

  17          say we have an array from a mysql query with the following fields: ID, NAME, AGE

  18          */
  19      $rows[1]=array(                /* add some data */
  20                              ID=>"38",
  21                              NAME=>"cranx",
  22                   AGE=>"20"
  23               );
  24      
  25      $rows[2]=array(                /* add some data */
  26                              ID=>"27",
  27                              NAME=>"ozsvar",
  28                              AGE=>"34"
  29                           );
  30  
  31      $rows[3]=array(            /* add some data */
  32                              ID=>"56",
  33                              NAME=>"alpi",
  34                              AGE=>"23"
  35                           );
  36  
  37      for ($i=1;$i<=3;$i++) {
  38          
  39          $xtpl->assign("DATA",$rows[$i]);        /* assign array data */
  40          $xtpl->assign("ROW_NR",$i);
  41          $xtpl->parse("main.table.row");            /* parse a row */
  42  
  43  /* 

  44      another way to do it would be:

  45  

  46          $xtpl->insert_loop("main.table.row",array(

  47                                                                                                  DATA=>$rows[$i],

  48                                                                                                  ROW_NR=>$i

  49                                                                                          ));

  50  

  51  */
  52      
  53      }
  54      
  55      $xtpl->parse("main.table");                    /* parse the table */
  56      
  57      $xtpl->parse("main");
  58      $xtpl->out("main");
  59  
  60  /*

  61  

  62          Revision 1.1  2004/05/27 05:30:47  sugarjacob

  63          Moving project to SourceForge.

  64  

  65          Revision 1.1  2004/05/19 01:48:20  sugarcrm

  66          Adding files with binary option as appropriate.

  67          

  68          Revision 1.2  2001/03/26 23:25:02  cranx

  69          added keyword expansion to be more clear

  70          

  71  */
  72  
  73  ?>


Généré le : Tue Sep 11 10:48:47 2007 par Balluche grâce à PHPXref 0.7