Mecha CMS

Mecha CMS blog and documentation.

Class Tree

Updated: Sunday, 07 August 2016

Convert array to list item.

Added since version 1.2.0.


Tree::$config = array(
    'trunk' => 'ul',
    'branch' => 'ul',
    'twig' => 'li',
    'classes' => array(
        'trunk' => 'trunk',
        'branch' => 'branch branch-%d',
        'twig' => 'twig',
        'current' => 'current',
        'chink' => 'chink'


Convert array to list item.

echo Tree::grow(array(
    'Example 1' => '/',
    'Example 2' => '/example',
    'Example 3' => '?example',
    'Example 4' => '#example',
    'Example 5' => 'javascript:void(0)',
    'Example 6' => array(
        'Example 6.1' => '/child-1',
        'Example 6.2' => '/child-2'
    'Example 7 (/parent)' => array(
        'Example 7.1' => '/parent/child-1',
        'Example 7.2' => '/parent/child-2'
    'Example 8',
    'Example 9' => null,
    'Example 10' => ""


<ul class="trunk">
  <li class="twig"><a href="">Example 1</a></li>
  <li class="twig"><a href="">Example 2</a></li>
  <li class="twig"><a href="?example">Example 3</a></li>
  <li class="twig"><a href="#example">Example 4</a></li>
  <li class="twig"><a href="javascript:void(0)">Example 5</a></li>
  <li class="twig ul">
    <span class="a">Example 6</span>
    <ul class="branch branch-1">
      <li class="twig"><a href="">Example 6.1</a></li>
      <li class="twig"><a href="">Example 6.2</a></li>
  <li class="twig ul">
    <a href="">Example 7</a>
    <ul class="branch branch-1">
      <li class="twig"><a href="">Example 7.1</a></li>
      <li class="twig"><a href="">Example 7.2</a></li>
  <li class="twig"><span class="a">Example 8</span></li>
  <li class="twig"><span class="a">Example 9</span></li>
  <li class="twig chink"></li>



tree:trunkWill affect the generated tree trunk.
tree:branchWill affect the generated tree branch.
tree:twigWill affect the generated tree twig.
tree:urlWill affect the generated tree URL.
tree:anchorWill affect the generated tree anchor and span tag.
trunkWill affect the generated trunk.
branchWill affect the generated branch.
twigWill affect the generated twig.
urlWill affect the generated URL.
anchorWill affect the generated anchor and span tag.



Donation and Email Subscription