2014-11-06 269 views
0

是否存在帶有下拉菜單的基於引導程序的邊欄導航面板?我看了很多,找不到一個。這裏是我當前的代碼(它創建了一個子菜單,但下拉列表已非功能):Bootstrap邊欄下拉菜單

  <div class="col-sm-3 col-md-2 sidebar">  
       <ul class="nav nav-sidebar">  
        <?php foreach ($this->container as $page): ?> 
         <?php if(! $page->isVisible() || !$this->navigation()->accept($page)) continue; ?> 
          <?php if(isset($page->pages) && count($page->pages)):?> 
           <li class="dropdown open"> 
          <a href="<?php echo $page->getHref() ?>" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"> 
           <?php echo $this->translate($page->getLabel()) ?> 
          </a> 
           <ul class="dropdown-menu" role="menu"> 
            <?php foreach($page->pages as $subpage):?> 
            <li> 
             <a href="<?php echo $subpage->getHref();?>"> 
              <?php echo $this->translate($subpage->getLabel());?> 
             </a> 
             <?php if(isset($subpage->pages) && count($subpage->pages)):?> 
              <ul class="dropdown-menu" role="menu"> 
              <?php foreach($subpage->pages as $innerpage):?> 
               <li> 
                <a href="<?php echo $innerpage->getHref();?>"> 
                 <?php echo $this->translate($innerpage->getLabel());?> 
                </a> 
               </li>  
              <?php endforeach;?> 
              </ul>  
             <?php endif;?> 
            </li> 
            <?php endforeach;?> 
           </ul> 
           <?php else:?> 
            <li> 
          <a href="<?php echo $page->getHref() ?>"> 
           <?php echo $this->translate($page->getLabel()) ?> 
          </a> 
          <?php endif;?>     
         </li> 
         <?php endforeach ?> 
        </ul> 
       </div> 

回答

0

幾個星期前,我有同樣的事情掙扎。我在你的代碼中發現了同樣的問題,所以我編輯了你的代碼,見下文。

試試這個:

<div class="col-sm-3 col-md-2 sidebar">  
      <ul class="nav nav-sidebar">  
       <?php foreach ($this->container as $page): ?> 
        <?php if(! $page->isVisible() || !$this->navigation()->accept($page)) continue; ?> 
         <?php if(isset($page->pages) && count($page->pages)):?> 
          <li class="dropdown open"> 
         <a href="<?php echo $page->getHref() ?>" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"> 
          <?php echo $this->translate($page->getLabel()) ?> 
         </a> 
          <ul class="dropdown-menu" role="menu"> 
           <?php foreach($page->pages as $subpage):?> 
            <li class="dropdown"> 
            <a href="<?php echo $subpage->getHref();?>"> 
             <?php echo $this->translate($subpage->getLabel());?> 
            </a> 
            <?php if(isset($subpage->pages) && count($subpage->pages)):?> 
             <ul class="dropdown-menu" role="menu"> 
             <?php foreach($subpage->pages as $innerpage):?> 
              <li class="dropdown"> 
               <a href="<?php echo $innerpage->getHref();?>"> 
                <?php echo $this->translate($innerpage->getLabel());?> 
               </a> 
              </li>  
             <?php endforeach;?> 
             </ul>  
            <?php endif;?> 
           </li> 
           <?php endforeach;?> 
          </ul> 
          <?php else:?> 
           <li> 
         <a href="<?php echo $page->getHref() ?>"> 
          <?php echo $this->translate($page->getLabel()) ?> 
         </a> 
         <?php endif;?>     
        </li> 
        <?php endforeach ?> 
       </ul> 
      </div> 
+0

所有你所做的就是更改類到下拉?對我來說它仍然不起作用。它會創建一個子菜單,但菜單會彈出而不是下拉菜單。 – jkushner 2014-11-06 20:55:50

+0

不改變,增加(只是爲了澄清)。我會玩弄它,看看我能找到什麼。 – Becandoo 2014-11-06 20:58:46

+0

http://postimg.org/image/wlte7slgd/ – jkushner 2014-11-06 21:00:48

0

這個怎麼樣:

<div class="container"> 
<div class="row"> 
    <div class="col-sm-2"> 
     <nav class="nav-sidebar"> 
      <ul class="nav">  
       <?php foreach ($this->container as $page): ?> 
        <?php if(! $page->isVisible() || !$this->navigation()->accept($page)) continue; ?> 
         <?php if(isset($page->pages) && count($page->pages)):?> 
          <li class="dropdown open"> 
         <a href="<?php echo $page->getHref() ?>" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"> 
          <?php echo $this->translate($page->getLabel()) ?> 
         </a> 
          <ul class="dropdown-menu" role="menu"> 
           <?php foreach($page->pages as $subpage):?> 
           <li class="dropdown"> 
            <a href="<?php echo $subpage->getHref();?>"> 
             <?php echo $this->translate($subpage->getLabel());?> 
            </a> 
            <?php if(isset($subpage->pages) && count($subpage->pages)):?> 
             <ul class="dropdown-menu" role="menu"> 
             <?php foreach($subpage->pages as $innerpage):?> 
              <li class="dropdown"> 
               <a href="<?php echo $innerpage->getHref();?>"> 
                <?php echo $this->translate($innerpage->getLabel());?> 
               </a> 
              </li>  
             <?php endforeach;?> 
             </ul>  
            <?php endif;?> 
           </li> 
           <?php endforeach;?> 
          </ul> 
          <?php else:?> 
           <li> 
         <a href="<?php echo $page->getHref() ?>"> 
          <?php echo $this->translate($page->getLabel()) ?> 
         </a> 
         <?php endif;?>     
        </li> 
        <?php endforeach ?> 
       </ul> 
       </nav> 
      </div> 
    </div> 

+0

沒有先生沒有工作。 – jkushner 2014-11-06 23:31:03

+0

我很好奇,你編輯過基本的bootstrap.css文件嗎?我想知道這些編輯是否會破壞你的代碼。 – Becandoo 2014-11-06 23:38:34