.. _zend.view.helpers.initial.htmllist:
HtmlList Helper
---------------
- ``htmlList($items, $ordered, $attribs, $escape)``: generates unordered and ordered lists based on the ``$items``
passed to it. If ``$items`` is a multidimensional array, a nested list will be built. If the ``$escape`` flag is
``TRUE`` (default), individual items will be escaped using the view objects registered escaping mechanisms; pass
a ``FALSE`` value if you want to allow markup in your lists.
Unordered list
^^^^^^^^^^^^^^
.. code-block:: php
:linenos:
$items = array(
'Level one, number one',
array(
'Level two, number one',
'Level two, number two',
array(
'Level three, number one'
),
'Level two, number three',
),
'Level one, number two',
);
echo $this->htmlList($items);
Output:
.. code-block:: html
:linenos:
- Level one, number one
- Level two, number one
- Level two, number two
- Level two, number three
- Level one, number two
Ordered list
^^^^^^^^^^^^
.. code-block:: php
:linenos:
echo $this->htmlList($items, true);
Output:
.. code-block:: html
:linenos:
- Level one, number one
- Level two, number one
- Level two, number two
- Level three, number one
- Level two, number three
- Level one, number two
HTML attributes
^^^^^^^^^^^^^^^
.. code-block:: php
:linenos:
$attribs = array(
'class' => 'foo',
);
echo $this->htmlList($items, false, $attribs);
Output:
.. code-block:: html
:linenos:
- Level one, number one
- Level two, number one
- Level two, number two
- Level two, number three
- Level one, number two
Escape Output
^^^^^^^^^^^^^
.. code-block:: php
:linenos:
$items = array(
'Level one, number one',
'Level one, number two',
);
// Escape output (default)
echo $this->htmlList($items);
// Don't escape output
echo $this->htmlList($items, false, false, false);
Output:
.. code-block:: html
:linenos:
- Level one, number <strong>one</strong>
- Level one, number <em>two</em>
- Level one, number one
- Level one, number two