Use of Lister

Lister probably is one of the fundamental and simplest objects in Agile Toolkit. It lays foundation to a more sophisticated classes such as CompleteLister , Grid and therefore contributes towards CRUDs and other objects.

$page->add('Lister')
  ->
setSource(array('One','Two','Three'));

You must strongly consider using setModel before using any other source type.

Use with Model

$page->add('Lister')
  ->
setModel('User');

Lister will automatically check what keys you've got in the template and will automatically configure your model to select those fields (actual fields) to speed up calculation.

Using with associative arrays

$page->add('Lister')
  ->
setSource(array(
    
5=>'John',
    
7=>'Steve'
  
));

The key becomes the value for "id" field and value becomes "name"

Using with array of hashes

$page->add('Lister')
  ->
setSource(array(
    array(
'id'=>5,'name'=>'John'),
    array(
'id'=>7,'name'=>'Steve'),
  ));

Natuarlly you are not limited only to those fields. You may specify any set of fields.

Using with Iterator

$page->add('Lister')
  ->
setSource(new DirectoryIterator('.'));

Any iterator may be used. If iterator returns array, it will be populated into the fields. Otherwise you need to redefine formatRow() function and read $this->current_row value which was returned from the iterator.