Re: Structures_DataGrid_Renderer_Smarty
| From: | Shin Ohno | Date: | Fri, 20 Oct 2006 08:33:34 +0000 |
| Subject: | Re: Structures_DataGrid_Renderer_Smarty | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25570@lists.php.net to get a copy of this message | ||
Hi,
I have an example of the Structures_DataGrid_Renderer_Smarty.
On 10/19/06, Chris Boget <chris.boget@wild.net> wrote:
Is there an example out there illustrating how to utilize this renderer? I've searched on Google and came up short. Unfortunately, the documentation is minimal and the only code example given is for the template. What about the rest of it? How do you set up the interaction between Smarty and DataGrid?Mark has already replied this, so maybe it does not need, but just give you a short script, and it works. -- <?php require_once 'Smarty/Smarty.class.php'; require_once 'Structures/DataGrid.php'; $pearPackages = array(
array('id' => 1, 'package' => 'DB', '# of downloas'
=> 1880131),
array('id' => 2, 'package' => 'PEAR', '# of downloas'
=> 1404515),
array('id' => 3, 'package' => 'Net_Socket', '# of downloas'
=> 1327259),
array('id' => 4, 'package' => 'Mail', '# of downloas'
=> 1063157),
array('id' => 5, 'package' => 'PHPUnit', '# of downloas'
=> 1060862),
array('id' => 6, 'package' => 'Net_SMTP', '# of downloas'
=> 952771),
array('id' => 7, 'package' => 'Archirve_Tar', '# of downloas'
=> 942372),
array('id' => 8, 'package' => 'Console_Getopt', '# of downloas'
=> 941070),
array('id' => 9, 'package' => 'Log', '# of downloas'
=> 785971),
array('id' => 10, 'package' => 'Mail_Mime', '# of downloas'
=> 531212),
);
$dg =& new Structures_DataGrid(4);$smarty =& new Smarty; $result = $dg->bind($pearPackages); PEAR::isError($result) or $result = $dg->fill($smarty); if (!PEAR::isError($result)) { // pear.tpl is same as the sample in http://pear.php.net/manual/en/package.structures.structures-datagrid.structures-datagrid-renderer.smarty.php $smarty->display('pear.tpl'); } else { $smarty->assign('error', 'DataGrid return PEAR Error'); $smarty->dispay('error.tpl'); } ?> -- Shin