Jump to content

Dynamically Created Navigation


Xtremer360

Recommended Posts

I'm trying to take my php output and using the HTML nav structure that is currently there turn it into dynamically generated menu using my result set. Any help on helping me figure out how to correct this.

 

Here's my output.

array(3) {
    [0]=> object(stdClass)#24 (3) {
        ["category_id"]=> string(1) "1"
        ["category_name"]=> string(9) "Dashboard"
        ["category_class"]=> string(9) "dashboard"
    }
    [1]=> object(stdClass)#24 (3) {
        ["category_id"]=> string(1) "2"
        ["category_name"]=> string(5) "Users"
        ["category_class"]=> string(5) "users"
    }
    [2]=> object(stdClass)#24 (3) {
        ["category_id"]=> string(1) "3"
        ["category_name"]=> string(5) "Pages"
        ["category_class"]=> string(5) "pages"
        ["links"]=> array(2) {
            [0]=> object(stdClass)#24 (2) {
                ["item_id"]=> string(1) "1"
                ["item_name"]=> string(5) "Admin Pages"
            [1]=> object(stdClass)#24 (2) {
                ["item_id"]=> string(1) "2"
                ["item_name"]=> string(5) "User Pages"
            }
        }
    }
}

I'm wanting to take my php output and using the HTML code below make a dynamic navigation.

<li class="active"><a href="" class="glyphicons dashboard"><i></i><span>Dashboard</span></a></li>
<li class="hasSubmenu">
    <a href="#menu_character" data-toggle="collapse" class="glyphicons page"><i></i><span>Pages</span><span class="icon-chevron-down"></span></a>
    <ul class="collapse" id="menu_character">
        <!-- Components Submenu Regular Items -->
        <li class=""><a href="">Item 1</a></li>
        <li class=""><a href="">Item 2</a></li>
        <!-- // Components Submenu Regular Items END -->
    </ul>
</li>

This is what I have so far.

<?php 
foreach ($dashboard_menu_categories AS $category)
{
    echo '<li>';
     if (isset($category->links))
     {
         echo '<ul class="collapse" id="menu_'.$category->category_short_name.'">';
         /* Components Submenu Regular Items */
         foreach($category->links AS $item)
         {
             echo '<li class=""><a href="">'.$item->item_name.'</a></li>';
         }
         /* Components Submenu Regular Items END */
         echo '</ul>';
    }
    echo '<a href="" class="glyphicons '.$category->category_class.'"><i></i><span>'.$category->category_name.'</span></a>';
    echo '</li>';
}
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.