Skip to content

Instantly share code, notes, and snippets.

@mkay
Created June 8, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkay/f0afc97ec1536932e0a3 to your computer and use it in GitHub Desktop.
Save mkay/f0afc97ec1536932e0a3 to your computer and use it in GitHub Desktop.
Bootstrap 3 navbar with MODX
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle collapsed" data-target="#navbar-collapse" data-toggle="collapse" type="button">
<span class="sr-only">Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
[[Wayfinder? &startId=`[[++site_start]]` &level=`2` &outerClass=`nav navbar-nav` &parentClass=`dropdown` &innerClass=`dropdown-menu` &parentRowTpl=`navbar_parentRowTpl`]]
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<li[[+wf.id]][[+wf.classes]] class="dropdown" id="menu[[+id]]">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#menu[[+id]]" href="[[+wf.link]]" title="[[+wf.title]]">
[[+wf.linktext]]
<b class="caret"></b>
</a>
[[+wf.wrapper]]</li>
@mkay
Copy link
Author

mkay commented Jun 8, 2015

Simple dynamic vanilla Boostrap Navigation with one-level dropdown menu.
Requires nothing but a chunk for parentRowTpl.
(if you don't use [[++site_start]] in your context(s), replace it with your menu's parent resource ID)

Requirements:

  • MODX 2.x
  • WayFinder (Extra)

@dannevang
Copy link

Can recommend you testing pdoMenu from the pdoTools package instead of wayfinder. You can use it the same way and it's a lot faster.

@mkay
Copy link
Author

mkay commented Jun 8, 2015

Thanks for the hint. Might give pdoMenu another try. Last time I checked it seemed rather beta'ish and underdocumented. Seems to have changed now.

@abhilashkrishnan
Copy link

I am unable to get the dropdown. Please respond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment