MLM(Multi Level Marketing) Website Using PHP - Binary Plan

Part 4 - Create Dynamic Menu

In this tutorial, we shall create our dynamic menu to avoid code duplicity and make it simple. If we will not make it dynamic then we need to create the menu for every page and whenever any changes occur in the menu then we need to change in all the pages one by one.

To create the dynamic menu we need to do following steps.

  • First, delete all the extra menu from the template that we do not want.
  • Create a folder php-includes, so we can put our all the included file in one folder.
  • Now create a file menu.php and save it within php-includes folder.
  • Copy the menu content and paste it to menu.php.
  • Now include the menu.php to all the pages where we need the menu.
  • Great!!! it's done. Now we have our own dynamic menu.



menu.php

<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="index.html">SB Admin v2.0</a>
    </div>
    <!-- /.navbar-header -->
    
    <ul class="nav navbar-top-links navbar-right">
        
        <!-- /.dropdown -->
        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu dropdown-message">
                <li><a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a>
                </li>
                <li><a href="#"><i class="fa fa-gear fa-fw"></i> Settings</a>
                </li>
                <li class="divider"></li>
                <li><a href="logout.php"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
                </li>
            </ul>
            <!-- /.dropdown-user -->
        </li>
        <!-- /.dropdown -->
    </ul>
    <!-- /.navbar-top-links -->
    
    <div class="navbar-default sidebar" role="navigation">
        <div class="sidebar-nav navbar-collapse">
            <ul class="nav" id="side-menu">
                <li>
                    <a href="home.php"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>
                </li>
                <li>
                    <a href="pin-request.php"><i class="fa fa-adjust fa-fw"></i> Pin Request</a>
                </li>
                <li>
                    <a href="pin.php"><i class="fa fa-adjust fa-fw"></i>View Pin</a>
                </li>
                <li>
                    <a href="join.php"><i class="fa fa-adjust fa-fw"></i>Join User</a>
                </li>
                <li>
                    <a href="tree.php"><i class="fa fa-adjust fa-hub"></i>Tree</a>
                </li>
            </ul>
        </div>
        <!-- /.sidebar-collapse -->
    </div>
<!-- /.navbar-static-side -->
</nav>                        


2438