Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Tree Menu
#1

[eluser]neillyons.co[/eluser]
CodeIgniter Tree Menu

Using CodeIgniter's ul function ( line 61 ../system/helpers/html_helper.php ) to render the output for the menu, I need to generate and format an array to pass as the first parameter, can anyone help?

Each menu item has a parent, which is the id of the parent menu item. If a menu has no parent selected it will default to 0. Zero is the root.


Database schema:

Code:
menu
id, name, parent, weight, created, updated


Format of the array to pass:

Code:
$data["Animal"]["Mammal"][] = "Cat";
$data["Animal"]["Mammal"]["Dog"][] = "Terrier";
$data["Animal"]["Mammal"]["Dog"][] = "Sheep dog";
$data["Animal"]["Bird"]["Owl"][] = "Barn Owl";

The above array when passed to ul function would produce the following HTML.

Code:
<ul>
  <li>Animal
    <ul>
      <li>Mammal
        <ul>

          <li>Cat</li>
          <li>Dog
            <ul>
              <li>Terrier</li>
              <li>Sheep dog</li>
            </ul>
          </li>
        </ul>

      </li>
      <li>Bird
        <ul>
          <li>Owl
            <ul>
              <li>Barn Owl</li>
            </ul>
          </li>
        </ul>

      </li>
    </ul>
  </li>
</ul>


I need to dynamicly produce this array from the information in the database.

Let me know if you can help.


Messages In This Thread
CodeIgniter Tree Menu - by El Forum - 07-14-2009, 02:06 PM
CodeIgniter Tree Menu - by El Forum - 07-14-2009, 02:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB