[ Index ] |
|
Code source de PHP PEAR 1.4.5 |
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 /** 4 * An example for the usage of ITX::addBlockfile 5 * 6 * @version CVS: $Id: sample_itx_addblockfile.php,v 1.1 2006/07/11 21:56:05 dsp Exp $ 7 */ 8 9 require_once 'HTML/Template/ITX.php'; 10 11 $data = array (array ('packagename'=>'mypackage', 12 'version' =>'1.0', 13 'changelog' => array ('fix bug #002', 14 'add author FOO to AUTHORS') 15 ), 16 array ('packagename'=>'mypackage', 17 'version' =>'1.0 RC 1', 18 'changelog' => array ('fix bug #002', 19 'added method foo()') 20 ) 21 ); 22 23 $tpl = new HTML_Template_ITX('./templates'); 24 $tpl->loadTemplatefile('addblockfile_main.tpl.htm', true, true); 25 26 // The complete content of "addblockfile_main.tpl.htm" will be loaded into a block 27 // called "list_template". The placeholder {DESCRIPTION} will be replaced 28 // with the added block "list_template". 29 $tpl->addBlockfile('DESCRIPTION', 'list_template', 'addblockfile_list.tpl.htm'); 30 31 32 // we now have the following blocks loaded: 33 // __global__, row, list_template and listelement 34 // lets assign the data. 35 foreach ($data as $entry) { 36 // assign data to the inner block (listelement) of list_template. 37 $tpl->setCurrentBlock('listelement'); 38 foreach ($entry['changelog'] as $changelogentry) { 39 $tpl->setVariable('ENTRY', $changelogentry); 40 $tpl->parseCurrentBlock(); 41 } 42 43 // assign data to the added list_template block 44 $tpl->setCurrentBlock('list_template'); 45 $tpl->setVariable('LISTNAME', $entry['version']); 46 $tpl->parseCurrentBlock(); 47 48 // back in the original templatefile we assign data to the row block 49 // notice: 50 // {DESCRIPTION} is not longer available, because it was replaced by the 51 // list_template block 52 $tpl->setCurrentBlock('row'); 53 $tpl->setVariable('NAME', $entry['packagename']); 54 $tpl->parseCurrentBlock(); 55 } 56 57 $tpl->show(); 58 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 14:08:00 2007 | par Balluche grâce à PHPXref 0.7 |