2016-08-15 32 views
1

我正在使用opencart v2.2.0,並具有面包屑導航的代碼。這個麪包屑將類別顯示爲下拉菜單。我如何編輯這個麪包屑刪除該下拉菜單,並只顯示正確的類別和子類別?如何從opencart 2.2 breadcrumb中刪除下拉菜單?

這裏是它如何工作的一個截圖: breadcrumb screen shot

這裏是代碼:

<div class="breadcrumb <?php if($theme_options->get('breadcrumb_layout') == 2) { echo 'fixed'; } else { echo 'full-width'; } ?>"> 
<div class="background-breadcrumb"></div> 
<div class="background"> 
    <div class="shadow"></div> 
    <div class="pattern"> 
     <div class="container"> 
      <div class="clearfix"> 
       <ul> 
        <?php 
        $i = 0; 
        $next_cat_id = 0; 
        foreach ($breadcrumbs as $breadcrumb) { 
         $cats = array(); 
         if($registry->get('request')->get['route'] == 'product/product' || $registry->get('request')->get['route'] == 'product/category'){ 
          if($i == 1){ 
           $cats = $theme_options->getCategories(0); 
          }else if($next_cat_id > 0 && count($breadcrumbs)-1 > $i){ 
           $cats = $theme_options->getCategories($next_cat_id); 
          } 
         } 


        ?> 
        <li class="item <?php echo !empty($cats) ? 'dropdown' : '';?>"> 
         <a <?php echo !empty($cats) ? 'class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"' : '';?> 
          href="<?php echo $breadcrumb['href']; ?>"><?php if($breadcrumb['text'] != '<i class="fa fa-home"></i>') { echo $breadcrumb['text']; } else { if($theme_options->get('home_text', $config->get('config_language_id')) != '') { echo $theme_options->get('home_text', $config->get('config_language_id')); } else { echo 'Home'; } } ?></a> 

         <?php if(!empty($cats)):?> 
         <ul class="dropdown-menu"> 
          <li> 
           <?php foreach($cats as $cat):?> 
           <?php if($cat['label'] == $breadcrumb['text']):?> 
            <?php $next_cat_id = $cat['category_id']; continue; ?> 
           <?php endif; ?> 
           <a href="<?php echo $cat['href'] ?>"><?php echo $cat['label'] ?></a> 
           <?php endforeach; ?> 
          </li> 
         </ul> 
         <?php endif; ?> 

        </li> 
        <?php $i++; } ?> 
       </ul> 
<!--     <h1 id="title-page"><?php echo $heading_title; ?> 
        <?php if(isset($weight)) { if ($weight) { ?> 
        &nbsp;(<?php echo $weight; ?>) 
        <?php } } ?> 
       </h1> 
       <div class="strip-line"></div>--> 
      </div> 
     </div> 
    </div> 
</div> 

+0

未回答請嗎?!! – vaguemind

+0

這不是核心opencart代碼。 這是自定義主題的代碼。 分析代碼我可以說的是: 評論以下行: $ cats = $ theme_options-> getCategories($ next_cat_id); 所有代碼都是自定義主題編寫的。通過上面的評論,它可能不會進入下一級別類別,只顯示頂級類別。 –

+0

雅,我知道它的一個自定義代碼,我不想阻止去下一個級別類別,我只需要刪除下拉,並正常工作像默認的opencart麪包屑? – vaguemind

回答

0

我不知道這個代碼,所以要小心結束div和其他的HTML。 正如我每個代碼,我已經刪除其他級別和下拉。我認爲$ breadcrumbs數組是作爲默認代碼返回的。如果他們改變了它,那麼也需要在控制器部分進行更改。希望以下將起作用。

<div class="breadcrumb <?php if($theme_options->get('breadcrumb_layout') == 2) { echo 'fixed'; } else { echo 'full-width'; } ?>"> 
<div class="background-breadcrumb"></div> 
<div class="background"> 
    <div class="shadow"></div> 
    <div class="pattern"> 
     <div class="container"> 
      <div class="clearfix"> 
       <ul> 
        <?php 
        foreach ($breadcrumbs as $breadcrumb) { ?> 
         <li class="item"> 
          <a 
           href="<?php echo $breadcrumb['href']; ?>"><?php if($breadcrumb['text'] != '<i class="fa fa-home"></i>') { echo $breadcrumb['text']; } else { if($theme_options->get('home_text', $config->get('config_language_id')) != '') { echo $theme_options->get('home_text', $config->get('config_language_id')); } else { echo 'Home'; } } ?></a>  
         </li> 
         <?php } ?> 
       </ul> 
<!--     <h1 id="title-page"><?php echo $heading_title; ?> 
        <?php if(isset($weight)) { if ($weight) { ?> 
        &nbsp;(<?php echo $weight; ?>) 
        <?php } } ?> 
       </h1> 
       <div class="strip-line"></div>--> 
</div> 
</div> 
</div> 
</div> 
+0

我實現了你的代碼,並給了我這個截圖:http://tinypic.com/r/504oj9/9 – vaguemind

+0

請刪除$ i ++; –

+0

雅,它現在的工作,非常感謝 – vaguemind