Instantly share code, notes, and snippets.
Created
August 20, 2013 22:41
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save trentsnippets/6288271 to your computer and use it in GitHub Desktop.
Add's Bootstrap navigation menu to a silverstripe template. Also includes another menu for mobile devices which can be removed if not making responsive site. The mobile menu is in two columns for this gist simply put it into one if that is what you require.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Nav --> | |
<div id="navbar" class="navbar navbar_absolute"> | |
<div class="container"> | |
<a class="brand" href="{$BaseHref}"><img src="{$ThemeDir}/img/logo.gif" alt="Logo" /></a> | |
<% if $Menu(1) %> | |
<ul class="nav"> | |
<% loop $MenuSet('Main Menu').MenuItems %> | |
<%-- Dropdown Menu --%> | |
<% if $Children %> | |
<li class="dropdown $LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown">$MenuTitle <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
<% loop $Children %> | |
<li class="$LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="$Link" title="Go to the $Title page"> | |
$MenuTitle | |
</a> | |
</li> | |
<% if $Children %> | |
<% loop $Children %> | |
<li class="$LinkingMode second-child"> | |
<a href="$Link" title="Go to the $Title page"> | |
- $MenuTitle | |
</a> | |
</li> | |
<% end_loop %> | |
<% end_if %> | |
<% end_loop %> | |
</ul> | |
</li> | |
<% else %> | |
<%-- End Dropdown Menu --%> | |
<%-- Single Menu Item --%> | |
<li class="$LinkingMode<% if $Last %> last<% end_if %>"><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> | |
<%-- End Single Menu Item --%> | |
<% end_if %> | |
<% end_loop %> | |
</ul> | |
<% end_if %> | |
<img src="{$ThemeDir}/img/mobile_button.jpg" alt="Mobile Nav Button" class="mobile_nav_button" /> | |
<%-- Mobile Menu --%> | |
<div class="mobile_nav" id="mobile_nav"> | |
<div class="mobile_contact"> | |
<p class="talk">TALK TO US <span class="white">0800 833 822</span></p> | |
<a href="{$BaseHref}contact-us" class="contact">CONTACT US</a> | |
</div> | |
<div class="mobile-nav-col1"> | |
<ul class="mobile_nav_list mobile_nav_list_col1"> | |
<% loop $MenuSet('Mobile Menu Col 1').MenuItems %> | |
<%-- Sub Menu --%> | |
<% if $Children %> | |
<li class="mobile_link $LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="#" class="mobile_heading" data-toggle="dropdown">$MenuTitle</a> | |
<ul class="mobile_sub_menu"> | |
<% loop $Children %> | |
<li class=" mobile_sub_list_item $LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="$Link" title="Go to the $Title page" class="mobile_sub_link"> | |
$MenuTitle | |
</a> | |
</li> | |
<% if $Children %> | |
<% loop $Children %> | |
<li class="mobile_sub_list_item $LinkingMode second-child"> | |
<a href="$Link" title="Go to the $Title page" class="mobile_sub_link"> | |
- $MenuTitle | |
</a> | |
</li> | |
<% end_loop %> | |
<% end_if %> | |
<% end_loop %> | |
</ul> | |
</li> | |
<% else %> | |
<%-- End Sub Menu --%> | |
<li class="mobile_link $LinkingMode<% if $Last %> last<% end_if %>"><a href="$Link" title="Go to the $Title page" class="mobile_heading $LinkingMode">$MenuTitle</a></li> | |
<%-- End Single Menu Item --%> | |
<% end_if %> | |
<% end_loop %> | |
</ul> | |
</div><%-- End Col1 --%> | |
<div class="mobile-nav-col2"> | |
<ul class="mobile_nav_list"> | |
<% loop $MenuSet('Mobile Menu Col 2').MenuItems %> | |
<%-- Sub Menu --%> | |
<% if $Children %> | |
<li class="mobile_link $LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="#" class="mobile_heading" data-toggle="dropdown">$MenuTitle</a> | |
<ul class="mobile_sub_menu mobile_nav_list_col2"> | |
<% loop $Children %> | |
<li class="mobile_sub_list_item $LinkingMode<% if $Last %> last<% end_if %>"> | |
<a href="$Link" title="Go to the $Title page" class="mobile_sub_link"> | |
$MenuTitle | |
</a> | |
</li> | |
<% end_loop %> | |
</ul> | |
</li> | |
<% else %> | |
<%-- End Sub Menu --%> | |
<li class="mobile_link $LinkingMode<% if $Last %> last<% end_if %>"><a href="$Link" title="Go to the $Title page" class="mobile_heading $LinkingMode">$MenuTitle</a></li> | |
<%-- End Single Menu Item --%> | |
<% end_if %> | |
<% end_loop %> | |
</ul> | |
</div><%-- End Col2 --%> | |
</div> | |
<%-- End Mobile Menu --%> | |
</div> | |
</div> | |
<!-- End Nav --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment