Digger HTML Class.
More...
|
static | arrayToList ($array, $listType='ul', $arrayAttributes=null, $callback=null) |
|
static | getElement ($tag, $body='', $arrayAttributes=null, $callback=null) |
|
Digger HTML Class.
Class for HTML represents of data.
- Version
- 3.0
- Author
- Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru
- Copyright
- (c) 2015, SAD-Systems
static arrayToList |
( |
|
$array, |
|
|
|
$listType = 'ul' , |
|
|
|
$arrayAttributes = null , |
|
|
|
$callback = null |
|
) |
| |
|
static |
To creates a simple HTML list from an input array.
- Parameters
-
array | $array | Input array. |
string | $listType | (Option) Type of main tag (UL | OL) |
array | $arrayAttributes | Array of attributes of main tag: ['class' => '...', 'id' => ... ] |
function | $callback | Callback function (on befor create item) |
- See also
- getElement
- Returns
- string HTML code.
Example:
echo
Html::arrayToList([
'a'=>[
'b'=>[
'c'=>
'value']]],
'ul', [
'id'=>
'myID1',
'class'=>
'myclass']);
<ul id="myID1" class="myclass">
<li>a
<ul>
<li>b
<ul>
<li>value</li>
</ul>
</li>
</ul>
</li>
</ul>
static getElement |
( |
|
$tag, |
|
|
|
$body = '' , |
|
|
|
$arrayAttributes = null , |
|
|
|
$callback = null |
|
) |
| |
|
static |
To create an html element
- Parameters
-
string | $tag | Html tag name (a, ul, li ...) |
string | $body | It is a text will be placed inside the tag. |
array | $arrayAttributes | Array of tag attributes: ['class' => '...', 'id' => ... ] |
function | $callback | This function will be called with given parameters: $tag, $body, $arrayAttributes that can be changed before creating the element. |
- Returns
- string HTML code.
Example:
echo
Html::getElement(
'a',
'my link', [
'href' =>
'http://somewere'],
function(&$tag, &$body, &$attr){ $body .=
'... some body ...'; $attr[
'class']=
'new class'; });
<a href="http://somewere" class="new class">my link... some body ...</a>
The documentation for this class was generated from the following file: