Class HtmlList
- HtmlElement
- HtmlList
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Create html lists
This class creates html list elements. Create a list object for ordered, unordered or data list an add the list items. The class supports data lists and lists and combination of nested lists and data lists. The parsed list object is returned as string.
Class: HtmlList
Code:
// Get instance $list = new HtmlList('dl', 'id_dl', 'class'); // Parameter for list type, id and class are optional ( Default list type = ul ) // In html strict a data list is determined to be nested in a list element if used in an ordered/unordered list $list->addListItem(); // add 2 list items term and description as string. Arrays are not supported! $list->addDataListItems('term_1', 'Listdata_1'); $list->addDataListItems('term_2', 'Listdata_2'); // get parsed datalist as string echo $list->getHtmlList();
Code:
// Get Instance $list = new HtmlList('ol', 'id_ol', 'class'); // Set type Attribute $list->addAttribute('type', 'square'); // Define a list element with ID "Item_0" and data "Listdata_1" as string $list->addListItem('Item_0', 'Listdata_1'); // Next list elements: Defining a term, a datalist is automatically nested in the list element $list->addListItem('Item_1', 'Listdata_2', 'term_2'); $list->addListItem('Item_2', 'Listdata_3', 'term_3'); $list->addListItem('Item_3', 'Listdata_4', 'term_4'); // Also manually configuration is possible // Define list element "li" with attribute ID = Item_5 $list->addListItem('Item_5'); // Define datalist in link element $list->addDataList(); // Define several term and description of the data list $list->addDataListItems('term_5', 'Listdata_5'); list->addDataListItems('term_5.1', 'Listdata_5.1'); list->addDataListItems('term_5.2', 'Listdata_5.2'); // get parsed datalist as string echo $list->getHtmlList();
Endcode
Endcode
Par: Example 1: Creating datalist
Par: Example 2: Creating ordered list
Located at htmllist.php
Methods summary
public
|
#
__construct( string $list = 'ul', string $id = null, string $class = null )
Constructor creates the element |
public
|
#
addDataList( string $id = null, string $term = null, string $description = null )
Add datalist (dl). |
public
|
|
public
|
|
public
string
|
Methods inherited from HtmlElement
addAttribute()
,
addData()
,
addElement()
,
addHtml()
,
addParentElement()
,
closeParentElement()
,
getHtmlElement()
,
setAttributesFromArray()
Properties summary
Properties inherited from HtmlElement
$arrParentElements
,
$currentElement
,
$currentElementAttributes
,
$currentElementDataWritten
,
$htmlString
,
$mainElement
,
$mainElementAttributes
,
$mainElementWritten
,
$nesting
,
$parentFlag