Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.31 KB | None | 0 0
  1. <section class = "menu">
  2. <?php
  3.  
  4. // function display_menu()
  5. // {
  6.        
  7.      $menu = Array(
  8.                 "1" => Array (
  9.                                 "title" => 'Add task',
  10.                                 "page"  => 'add_task',
  11.                                 "url"   => "add_task.php",
  12.                                 'children' => Array()
  13.                                         ),
  14.                 "2" => Array (
  15.                                 "title" => "Today",
  16.                                 "page"  => 'today',
  17.                                 "url"   => "main_page.php",
  18.                                 'children' => Array()                                  
  19.                                         ),                                      
  20.                 "3" => Array (
  21.                                 "title" => 'Week',
  22.                                 "page"  => 'week',
  23.                                 "url"   => "" ,
  24.                                 'children' => Array()                              
  25.                                         ),
  26.                 "4" => Array (
  27.                                 "title" => 'Show all',
  28.                                 "page"  => 'show all',
  29.                                 "url" => "",
  30.                                 "children" => Array(
  31.                                             "1" =>
  32.                                                 Array (
  33.                                                     'title' => 'Categories',
  34.                                                     'url' => 'index.php',
  35.                                                     'children' => Array(
  36.                                                    
  37.                                                     "1" =>
  38.                                                         Array (
  39.                                                             'title' => 'Work',
  40.                                                             'url' => 'index.php',
  41.                                                             'children' => Array(),
  42.                                                             ),
  43.                                                            
  44.                                                     "2" =>
  45.                                                         Array (
  46.                                                             'title' => 'House',
  47.                                                             'url' => 'index.php',
  48.                                                             'children' => Array(),
  49.                                                             ),
  50.                                                     "3" =>
  51.                                                         Array (
  52.                                                             'title' => 'Education',
  53.                                                             'url' => 'index.php',
  54.                                                             'children' => Array(),
  55.                                                             ),
  56.                                                     "4" =>
  57.                                                         Array (
  58.                                                             'title' => 'Entertainment',
  59.                                                             'url' => 'index.php',
  60.                                                             'children' => Array(),
  61.                                                             ),
  62.                                                     "5" =>
  63.                                                         Array (
  64.                                                             'title' => 'Other',
  65.                                                             'url' => 'index.php',
  66.                                                             'children' => Array(),
  67.                                                             ),
  68.                                                         ),
  69.                                                 ),
  70.                                                 "2" => Array (
  71.                                                     'title' => 'Frequently used tags',
  72.                                                     'url' => 'index.php',
  73.                                                     'children' => Array(
  74.                                                     "1" =>
  75.                                                         Array (
  76.                                                             'title' => 'Work',
  77.                                                             'url' => 'index.php',
  78.                                                             'children' => Array(),
  79.                                                             ),
  80.                                                            
  81.                                                     "2" =>
  82.                                                         Array (
  83.                                                             'title' => 'House',
  84.                                                             'url' => 'index.php',
  85.                                                             'children' => Array(),
  86.                                                             ),
  87.                                                     "3" =>
  88.                                                         Array (
  89.                                                             'title' => 'Education',
  90.                                                             'url' => 'index.php',
  91.                                                             'children' => Array(),
  92.                                                             ),
  93.                                                     "4" =>
  94.                                                         Array (
  95.                                                             'title' => 'Entertainment',
  96.                                                             'url' => 'index.php',
  97.                                                             'children' => Array(),
  98.                                                             ),
  99.                                                             ),
  100.                                                             ),
  101.                                                             ),
  102.                                                             ),
  103.                              
  104.                                              
  105.                                                    
  106.                 "5" => Array (
  107.                                 "title" => 'Tags',
  108.                                 "page"  => 'tags',
  109.                                 "url"   => ""            
  110.                                         ),
  111.                 "6" => Array (
  112.                             "title" => 'Settings',
  113.                             "page"  => 'settings',
  114.                             "url"   => ""            
  115.                                     ),
  116.                 "7" => Array (
  117.                             "title" => 'About us',
  118.                             "page"  => 'about',
  119.                             "url"   => "about.php"            
  120.                                     )
  121.                                        
  122.         );    
  123.          function buildMenu($makemenu)
  124.  {
  125.         echo "<nav>";
  126.         echo "<ul>";
  127.         //echo count($menu);
  128.         for ($i = 1; $i <= count($makemenu); $i++)
  129.         {
  130.                 echo '<li><a href= ' . $makemenu[$i]['url'] . '>' . $makemenu[$i]['title'] .'</a>';
  131.                  if ( ! empty($makemenu[$i]['children'])) {
  132.                     echo "<ul>";
  133.                     buildMenu($makemenu[$i]['children']);
  134.                     echo "</ul>";
  135.                 }
  136.                  echo "</li>";
  137.         }  
  138.        
  139.         echo "</ul>";
  140.         echo "</nav>";
  141.  
  142. }
  143. echo buildMenu($menu);
  144.  
  145. //}
  146.  
  147. ?>
  148.  
  149. </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement