Gumbo_Template_List



Template List Class (Special class for saving lists of data)

This is a Special Template Element designed to hold lists of data. The output is formatted specifically by the child class.

For example, using a string replacement Engine, looping through an array of data requires clever programming. However, the List class will hold the array of data and perform the loop internally, formatting the desired output. If the program requires placing list items 'li' inside an [un]ordered list 'ul' or 'ol', simply populate the List_Item class with the data and assign a Template Variable. When the Template File is parsed, the List object will replace the keyword with a formatted string.

 $tpl = new Gumbo_Template_Engine_[Name] ();
 ...
 $tpl_list = new Gumbo_Template_List_Item;
 $tpl_list->add ("some data");
 ...
 $tpl->assign ("My_List", $tpl_list);

 // inside template_file.txt
 ...
 {My_List}

To extend, create new List classes that work with specific types of elements. In HTML, this could be definition lists, table rows, [un]ordered list items, etc.

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Implements interfaces:

Child classes:

Class Variables

array $_elements = array () [line 66]

Class Methods

public void add ( arr[] $data ) [line 75]

Adds data to the end of the list

Parameter(s):

  • (arr[]) $data :: data arguments
  • abstract:  
Overridden in child classes as:
Gumbo_Template_List_Item::add()
Adds data to the end of the list


[ Top ]
public void display ( ) [line 90]

Displays to the browser


[ Top ]
public array getElements ( ) [line 130]

Returns all the elements


[ Top ]
public void place ( int $position, arr[] $data ) [line 82]

Places data at the specified location

Parameter(s):

  • (int) $position
  • (arr[]) $data :: data arguments
  • abstract:  
Overridden in child classes as:
Gumbo_Template_List_Item::place()
Places the data at the specified location


[ Top ]
public void remove ( int $position ) [line 99]

Removes data from a given position (resets the List)

Parameter(s):

  • (int) $position
  • throws:  Gumbo_Exception

[ Top ]