Skip to content

Commit 312dd45

Browse files
authored
Merge pull request #4 from timlenton/master
render bootstrap menu
2 parents c4b635a + e3983a4 commit 312dd45

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor
22
composer.phar
33
composer.lock
4-
.DS_Store
4+
.DS_Store
5+
.idea

src/LukeSnowden/Menu/Styles/Styles.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,34 @@ public static function renderNavTabsDropdowns( $structure = array(), $depth = 1
7979
if( $depth === 1 ) return ob_get_clean();
8080
}
8181

82+
/**
83+
* Render bootstrap menu
84+
*
85+
* @param array $structure
86+
* @param int $depth
87+
* @return string
88+
*/
89+
public static function renderBootstrapNav($structure = array(), $depth = 1 )
90+
{
91+
if( $depth === 1 ) ob_start();
92+
foreach( $structure as $level ) :
93+
$class = preg_replace( '/current/', 'active', $level['class'] );
94+
echo '<li class=" ' . $class . ' ' . ( empty( $level['children'] ) ? '' : 'dropdown' ) . '">';
95+
$icon = $level['icon'] ? '<i class="'.$level['icon'].'"></i>' : '' ;
96+
if( ! empty( $level['children'] ) ) :
97+
98+
echo '<a href="#" >'. $icon . $level['text'] . ' <span class="fa fa-chevron-down"></span></a>';
99+
echo '<ul class="nav child_menu" role="menu">';
100+
echo self::renderNavTabsDropdowns( $level['children'], ($depth+1) );
101+
echo '</ul>';
102+
else :
103+
echo '<a href="' . $level['URL'] . '">'. $icon . $level['text'] . '</a>';
104+
endif;
105+
echo '</li>';
106+
endforeach;
107+
if( $depth === 1 ) return ob_get_clean();
108+
}
109+
82110
}
83111

84-
?>
112+
?>

0 commit comments

Comments
 (0)