Re: nested blocks in templates

From: Date: Sun, 24 Nov 2002 19:00:17 +0000
Subject: Re: nested blocks in templates
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-11065@lists.php.net to get a copy of this message
My apologies. I meant to post this to the general list. Erica At 09:18 PM 11/23/02 -0800, you wrote: >Hello, > >I am learning HTML_Template_IT and I have a question about nesting blocks: > >I want to display 3 product sections, each of which has a pricing table with several price >points within it. I am pulling display information for the sections as well as the pricing from a >database. > >The problem is that the inner block for the pricing table executes only in the first loop >through the outer section block, so the first product section has pricing, but the successive >sections do not. Any suggestions on how to get the inner block to execute each time through the >outer block? > >TIA, >Erica > >I have set up my html template like this: >... ><!-- BEGIN section --> ><tr><td ><a >name="{ANCHOR}">{ITEM}</a></div></td></tr> > <tr><td > > <table> > <tr><td>Quantity</td><td>Unit > Cost</td><td>Total</td></tr> ><!-- BEGIN row --> > > <tr><td>{ITEMQTY}</td><td>${ITEMCOST}</td><td>${ITEMTOTAL}</td></tr> ><!-- END row --> > <tr><td>{ITEMLIMIT}</td><td>CALL US!</td><td>CALL > US!</td></tr> > </table> > </td></tr> ><!-- END section --> >... > >and my script like this: > >//start section block > while ($displayobj->fetchInto($sectionresult)) { > >//loop through row block > while ($priceobj->fetchInto($priceresult)) { > >//make sure to use row info related only to this section > if ($priceresult[0]==$sectionresult[0]) { > >//assign values to row block > $tpl->setCurrentBlock("row"); > $tpl->setVariable("ITEMQTY", $showqty); > $tpl->setVariable("ITEMCOST", $showsell); > $tpl->setVariable("ITEMTOTAL", $showtotal); > $tpl->parseCurrentBlock("row") ; > } >} > >//assign values to section block > $tpl->setCurrentBlock("section"); > $tpl->setVariable("ANCHOR", $sectionresult[1]); > $tpl->setVariable("ITEM", $sectionresult[2]); > $tpl->setVariable("ITEMLIMIT", $sectionresult[3]); > $tpl->parseCurrentBlock("section"); >} > >// print the output >$tpl->show(); > > > >-- >PEAR Development Mailing List (http://pear.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.dev (#11065) next »