Scroll to top

Haloo! Selamat Datang di Komunitas Private Training Web Development (36073 Members, 318 Projects, 3132 Topic, 8769 Comments)

Butuh karyawan baru? atau seorang Web Developer (Part-time/Freelance/Full-time) untuk mengerjakan project/aplikasi anda?, cari disini : Members Area Jobs!
SIKOLAG Ci - Merubah Struktur Menu Dropdown ke Bootstrap
Ahmad Adzan Azari Mengatakan : Members -
  1. Assalamualaikum mas..
  2. saya mau tanya untuk merubah menu dropdown di website SIKOLAG
  3.  
  4. Menu SIKOLAG
  5. ------------------------------------------------------------------------------------------------
  6. <div class='main-menu sticky'>
  7. <div class='wrapper'>";
  8. function main_menu() {
  9. $ci = & get_instance();
  10. $query = $ci->db->query("SELECT id_menu, nama_menu, link, id_parent FROM menu where aktif='Ya' AND position='Bottom' order by urutan");
  11. $menu = array('items' => array(),'parents' => array());
  12. foreach ($query->result() as $menus) {
  13. $menu['items'][$menus->id_menu] = $menus;
  14. $menu['parents'][$menus->id_parent][] = $menus->id_menu;
  15. }
  16. if ($menu) {
  17. $result = build_main_menu(0, $menu);
  18. return $result;
  19. }else{
  20. return FALSE;
  21. }
  22. }
  23.  
  24. function build_main_menu($parent, $menu) {
  25. $html = "";
  26. if (isset($menu['parents'][$parent])) {
  27. if ($parent=='0'){
  28. $html .= "<ul class='the-menu'>";
  29. }else{
  30. $html .= "<ul>";
  31. }
  32. foreach ($menu['parents'][$parent] as $itemId) {
  33. if (!isset($menu['parents'][$itemId])) {
  34. if(preg_match("/^http/", $menu['items'][$itemId]->link)) {
  35. $html .= "<li><a target='_BLANK' href='".$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu."</a></li>";
  36. }else{
  37. $html .= "<li><a href='".base_url().''.$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu."</a></li>";
  38. }
  39. }
  40. if (isset($menu['parents'][$itemId])) {
  41. if(preg_match("/^http/", $menu['items'][$itemId]->link)) {
  42. $html .= "<li><a target='_BLANK' href='".$menu['items'][$itemId]->link."'><span>".$menu['items'][$itemId]->nama_menu."</span></a>";
  43. }else{
  44. $html .= "<li><a href='".base_url().''.$menu['items'][$itemId]->link."'><span>".$menu['items'][$itemId]->nama_menu."</span></a>";
  45. }
  46. $html .= build_main_menu($itemId, $menu);
  47. $html .= "</li>";
  48. }
  49. }
  50. $html .= "</ul>";
  51. }
  52. return $html;
  53. }
  54. echo main_menu();
  55. echo "</div>
  56. </div>";
  57.  
  58.  
  59. Menu Yang diinginkan
  60. ------------------------------------------------------------------------------------------------
  61.  
  62. <nav>
  63. <div class="nav-wrapper">
  64. <a href="#!" class="brand-logo">Logo</a>
  65. <ul class="right hide-on-med-and-down">
  66. <li><a href="sass.html">Sass</a></li>
  67. <li><a href="badges.html">Components</a></li>
  68. <!-- Dropdown Trigger -->
  69. <li><a class="dropdown-button" href="#!" data-activates="dropdown1">Dropdown<i class="material-icons right">arrow_drop_down</i></a>
  70.  
  71. <ul id="dropdown1" class="dropdown-content">
  72. <li><a href="#!">one</a></li>
  73. <li><a href="#!">two</a></li>
  74. <li class="divider"></li>
  75. <li><a href="#!">three</a></li>
  76. </ul>
  77. </li>
  78. </ul>
  79. </div>
  80. </nav>
  81.  
  82. Mohon bantuannya mas. Terima Kasih
Robby Prihandaya Mengatakan :
Admin -
  1. Assalam, tinggal di sesauikan saja, itu pake struktur bootsrap ya mas..
  2. ini dulu pernah saya ubah ke struktur bootstrap :
  3.  
  4. <nav id="main-nav" class="main-nav navbar-inverse" role="navigation">
  5. <div class="navbar-header">
  6. <button class="navbar-toggle navbar-left" type="button" data-toggle="collapse" data-target="#navbar-collapse">
  7. <span class="sr-only">Toggle navigation</span>
  8. <span class="icon-bar"></span>
  9. <span class="icon-bar"></span>
  10. <span class="icon-bar"></span>
  11. </button><!--//nav-toggle-->
  12.  
  13. </div><!--//navbar-header-->
  14. <div class="navbar-collapse collapse navbar-custom1" id="navbar-collapse">
  15. <?php
  16. function main_menu() {
  17. $ci = & get_instance();
  18. $query = $ci->db->query("SELECT id_menu, nama_menu, link, id_parent FROM menu where aktif='Ya' AND position='Bottom' order by urutan");
  19. $menu = array('items' => array(),'parents' => array());
  20. foreach ($query->result() as $menus) {
  21. $menu['items'][$menus->id_menu] = $menus;
  22. $menu['parents'][$menus->id_parent][] = $menus->id_menu;
  23. }
  24. if ($menu) {
  25. $result = build_main_menu(0, $menu);
  26. return $result;
  27. }else{
  28. return FALSE;
  29. }
  30. }
  31.  
  32. function build_main_menu($parent, $menu) {
  33. $html = "";
  34. if (isset($menu['parents'][$parent])) {
  35. if ($parent=='0'){
  36. $html .= "<ul class='nav navbar-nav'>";
  37. }else{
  38. $html .= "<ul class='dropdown-menu'>";
  39. }
  40. foreach ($menu['parents'][$parent] as $itemId) {
  41. if (!isset($menu['parents'][$itemId])) {
  42. if(preg_match("/^http/", $menu['items'][$itemId]->link)) {
  43. $html .= "<li><a target='_BLANK' href='".$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu."</a></li>";
  44. }else{
  45. $html .= "<li><a href='".base_url().''.$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu."</a></li>";
  46. }
  47. }
  48. if (isset($menu['parents'][$itemId])) {
  49. if(preg_match("/^http/", $menu['items'][$itemId]->link)) {
  50. $html .= "<li><a class='dropdown-toggle nav-item' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false' target='_BLANK' href='".$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu." <span class='caret'></span></a>";
  51. }else{
  52. $html .= "<li><a class='dropdown-toggle nav-item' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false' href='".base_url().''.$menu['items'][$itemId]->link."'>".$menu['items'][$itemId]->nama_menu." <span class='caret'></span></a>";
  53. }
  54. $html .= build_main_menu($itemId, $menu);
  55. $html .= "</li>";
  56. }
  57. }
  58. $html .= "</ul>";
  59. }
  60. return $html;
  61. }
  62. echo main_menu();
  63. ?>
  64. </div><!--//navabr-collapse-->
  65.  
  66. </nav><!--//main-nav-->

Maaf, Untuk Memberikan Komentar Anda Harus Login !!!