HandyKit v2.1  

 Online
 Index page
 HowTo

HandyKIT packages

 HandyCGI.pm
 HandyList.pm
 HandyMail.pm
 HandyTemplate.pm
 HandyTextDB.pm
 SiteBag.pm

Other packages

 HandySQL.pm
 HandyLog.pm
 HandyCrypt.pm

NAME

HandyList - full-featured object to create HTML lists or tables.


SYNOPSIS

use vars qw($list);

use HandyTemplate; 
use HandyList;

sub example_main { 
	my ($offset,$limit) = $list->lock_range();

	# In real world following three lines should 
	# be replaced by SQL query
	my $dbt = ['login', 'password'];
	my $table = 
		[ ['test', 'test'], ['john', 'eZfH9212'] ];
	if ($offset == 1) {     
		shift(@$table); 
		}
	$list->fill($table, $dbt);
         $list = undef;
         return $_[0];
}

my $fp = {'main' => \&example_main};

&cgi_start(); 
$list = HandyList->new(2,\%fp,\%tvars,'');
&print_html(&load_template('list_test.html',$fp));
&cgi_finish();


DESCRIPTION

For each list generation object should be used in the following way:

# Construct object
  $list = HandyList->new(...); 
# Get range
  ($offset,$limit) = $list->lock_range(); 
# Fill template variables
  $list->fill($table,$dbt); 	  
new($count,$formprocs,$tvars,$prefix)
Creates new object, that will show with navigation up to $count elements ($count can be big number). Loads template functions (see HandyTemplate docs) into $formprocs hash. Reads/writes template variables to/from $tvars reference to hash. $prefix is usually left empty, but if you want to pack two lists in one HTML page, then you should make several lists with different prefixes. This $prefix will be appended before every template variable/function reference inside of HandyList engine code.

INPUT CGI PARAMETERS

$hin{'by'}
Column name for sorting.

$hin{'sr'}

Number of start row, that is printed first in this list.

INPUT TEMPLATE VARIABLES

list_maxelements
Number of elements that are printed in one screen.

list_navigator_element_sel
Selected element of navigator. In all list_navigator_element_* following replacements are working:
&by;=>current sorting;
&sr;=>start row;
&to;=>end row;
for this navigator element.

list_navigator_element_lone_sel
Selected alone element of navigator.

list_navigator_element
Unselected element of navigator.

list_navigator_element_lone
Unselected alone element of navigator.

list_navigator_separator
This string is inserted between consequent list_navigator_elements.

list_element
This string describes the element of list. Following replaces are taken:
&row;=>row number;
&rowcount;=>total number of rows;
&list_by;=>sorting parameter;
&list_sr;=>current starting row.
Plus all entities from $dbt reference to array are replaced.

list_element_d2
OPTIONAL. If list_element_d2 is present, then all odd rows will use this variable instead of list_element. This is useful to color differently odd/even rows.

list_separator
Separator code, that is inserted between list elements.

OUTPUT TEMPLATE VARIABLES

list_navigator
List navigator, composed by input list_navigator_* variables.

list_elements
List elements, composed by input list_element_* and list_separator variables.

list_sr
Current starting row.

list_by
Current sorting column.

TEMPLATE FUNCTIONS

&if_list_not_empty{list is not empty}{otherwise}
If list is not empty, then 'list is not empty' returned. Otherwise 'otherwise' is returned.

&if_by{orderby_column_name}{if_selected}{if_not_selected}
If $hin{'by'} eq 'orderby_column_name', then 'if_selected' is returned, otherwise 'if_not_selected' is returned.



TOP
© 2000 || Perl4YOU.com E-mail: info@perl4you.com