3 ms·
This uses my company's PHP templating engine (which is open source and available at http://tierratemplates.com http://tierratemplates.com) and our internal CMS
by dugmartin 16y ago
This uses my company's PHP templating engine (which is open source and available at http://tierratemplates.com http://tierratemplates.com) and our internal CMS framework:
// controller function
public getcolors($request) {
$db = CMS::GetDB();
$request->favcolor = $db->transform($db->getRows("select * from favcolor order by color, name"), "collect", "color");
}
// and the template
{@ favcolor ?
"<ul>"
`<li><strong>{$key}</strong>: {$:implode(", ")}</li>`
"</ul>" @}
the template uses a control structure called a conditerator (more info at the site). The controller uses a data transform to convert the set of rows into a hash of rows keyed on color.
I think that is more concise and reads better than the BRL example.