2016-07-19 77 views
0

是否有任何教程或模板創建的WordPress +木材+ bootstrap?Bootstrap + Wordpress +木材

我在與菜單的問題...

菜單head.twig:

<nav class="navbar navbar-custom"> 
    <div class="container-fluid"> 
     <!-- Brand and toggle get grouped for better mobile display --> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> 
       <span class="sr-only">Toggle 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> 

     <!-- Collect the nav links, forms, and other content for toggling --> 
     <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
      {% include "menu.twig" with {'menu': menu.get_items} %} 
     </div> 
     <!-- /.navbar-collapse --> 
    </div> 
    <!-- /.container-fluid --> 
</nav> 

menu.twig:

{% if menu %} 
<ul class="nav navbar-nav navbar-right"> 
    {# 
    <li><a href="#">Link</a></li>#} {% for item in menu %} 
    <li class="{{item.classes | join(' ')}}"> 
     <a href="{{item.get_link}}">{{item.title}}</a> {% include "menu.twig" with {'menu': item.get_children} %} 
    </li> 
    {% endfor %} 
</ul> 
{% endif %} 

和不幸的結果是這樣的一個: enter image description here

我不知道如何用th Ë子菜單被顯示爲下拉菜單......請幫助...

編輯:我會被移動到基礎... :)

回答

0

像這樣的東西應該工作

<div class="collapse navbar-collapse" id="navbarmain"> 
     <ul class="nav navbar-nav main-menu"> 
      {% for item in menu.get_items %} 
       <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="{{item.get_link}}">{{item.title}}<b class="caret"></b></a> 
        {% if item.get_children %} 
         <ul class="dropdown-menu" role="menu"> 
          {% for child in item.get_children %} 
           <li><a href="{{child.get_link}}" class="transition">{{child.title}}</a></li> 
          {% endfor %} 
         </ul> 
        {% endif %} 
       </li> 
      {% endfor %} 
     </ul> 
    </div> 
1

@曼森mamaril你只是缺少一個小一點的menu.twig。而不是{% for item in menu %}它應該是{% for item in menu.get_items %}

{% if menu %} 
<ul class="nav navbar-nav navbar-right"> 
    {# 
    <li><a href="#">Link</a></li>#} 
    {% for item in menu.get_items %} 
     <li class="{{item.classes | join(' ')}}"> 
      <a href="{{item.get_link}}">{{item.title}}</a> 
      {% include "menu.twig" with {'menu': item.get_children} %} 
     </li> 
    {% endfor %} 
</ul> 
{% endif %}