Re: nested loops and PHPLIB templates

From: Date: Mon, 09 Apr 2001 07:27:28 +0000
Subject: Re: nested loops and PHPLIB templates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47738@lists.php.net to get a copy of this message
Hello paula, Monday, April 09, 2001, 6:47:21 AM, you wrote: p> I was sending desperate emails to this list related to nested loops and array comparision. p> Well, just let you know that the problem seems to be that I'm using this with PHPLIB p> templates and those can't handle nested loops. template.html: <table> <!-- BEGIN row --> <tr> <!-- BEGIN column --> <td>{val}</td> <!-- END column --> </tr> <!-- END row --> </table> code: // place here some code for multi-row multi-column data array $tpl = new Template; $tpl->set_file('tp', 'template.html'); $tpl->set_block('tp', 'row', 'row_parsed'); $tpl->set_block('row', 'column', 'column_parsed'); foreach ($rows as $row => $columns) { /* IMPORTANT: free the column block from previous results, do it like this: */ $tpl->set_var('column_parsed', ''); foreach ($columns as $column) { $tpl->set_var('val', $column); $tpl->parse('column_parsed', 'column', true); } $tpl->parse('row_parsed', 'row', true); } $tpl->pparse('out', 'tp'); So, you have nested blocks filled with nested loops. -- Best regards, Maxim Derkachev mailto:kot@books.ru Symbol-Plus Publishing Ltd. phone: +7 (812) 324-53-53 http://www.Books.Ru -- All Books of Russia  

« previous php.general (#47738) next »