Advertisement
21ani

sidebar

Jan 12th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. <!-- Sidebar -->
  2. <div class="side">
  3.  
  4. <ul class="navbar-nav bg-gradient- sidebar sidebar-dark accordion" id="accordionSidebar">
  5.  
  6. <!-- Sidebar - Brand -->
  7. <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
  8.   <div class="sidebar-brand-icon rotate-n-15">
  9.     <i class="fas fa-laugh-wink"></i>
  10.   </div>
  11.   <div class="sidebar-brand-text mx-3">Skripsi</div>
  12. </a>
  13. <!-- Divider -->
  14. <hr class="sidebar-divider">
  15.  
  16. <!-- Nav Item - Dashboard -->
  17. <li class="nav-item active">
  18.   <a class="nav-link" href="<?= base_url('user'); ?>">
  19.     <i class="fas fa-fw fa-tachometer-alt"></i>
  20.     <span>Dashboard</span></a>
  21. </li>
  22.  
  23.  
  24.  
  25. <!-- query menu, melakukan join dari ke3  tabel(menu, sub menu, acces menu) -->
  26. <?php
  27. $role_id = $this->session->userdata('role_id');
  28. $queryMenu = "SELECT `user_menu`.`id`, `menu`
  29.                FROM `user_menu` JOIN `user_access_menu`
  30.                  ON `user_menu`.`id` = `user_access_menu`.`menu_id`
  31.               WHERE `user_access_menu`.`role_id` = $role_id
  32.            ORDER BY `user_access_menu`.`menu_id` ASC
  33.            ";
  34. $menu = $this->db->query($queryMenu)->result_array();
  35. // var_dump($menu);
  36. // die;
  37. ?>
  38.  
  39. <!-- LOOPING MENU -->
  40. <?php foreach ($menu as $m) : ?>
  41.             <div class="sidebar-heading">
  42.                 <?= $m['menu']; ?>
  43.             </div>
  44.  
  45.  <!-- SIAPKAN SUB-MENU SESUAI MENU -->
  46.  <?php
  47.             $menuId = $m['id'];
  48.             $querySubMenu = "SELECT *
  49.                               FROM `user_sub_menu` JOIN `user_menu`
  50.                                 ON `user_sub_menu`.`menu_id` = `user_menu`.`id`
  51.                              WHERE `user_sub_menu`.`menu_id` = $menuId
  52.                                
  53.                        ";
  54.             $subMenu = $this->db->query($querySubMenu)->result_array();
  55.             ?>
  56.  
  57.             <?php foreach ($subMenu as $sm) : ?>
  58.             <?php if ($title == $sm['title']) : ?>
  59.             <li class="nav-item active">
  60.                 <?php else : ?>
  61.             <li class="nav-item">
  62.                 <?php endif; ?>
  63.                 <a class="nav-link pb-0" href="<?= base_url($sm['url']); ?>">
  64.                     <i class="<?= $sm['icon']; ?>"></i>
  65.                     <span><?= $sm['title']; ?></span></a>
  66.             </li>
  67.             <?php endforeach; ?>
  68.  
  69.             <hr class="sidebar-divider mt-3">  
  70. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement