bootstrap 一頁多個輪播 結合samrty,bootstrapsamrty

來源:互聯網
上載者:User

bootstrap 一頁多個輪播 結合samrty,bootstrapsamrty

bootstrap一頁有多個輪播的時候,許多人會遇到只有一個輪播可以用,其他輪播都失效的情況。網上的資料也不多。其實會出現這樣的問題,應該是輪播的ID重複了,所以導致bootstrap 一頁多個輪播。

我在做項目的時候,結合smarty模板,可擴充的配置輪播,且實現了一個頁面又多個輪播的功能。

view層:

//測試資料    $result = '{          "service_type": "car",          "view": {              "picinfo": {                  "tag_name": "圖片資訊",                  "data": {                      "pic_1": {                          "explain": "車輛1",                          "type": "text",                          "options": "",                          "value": ["../../../web/images/id_card_po","../../../web/images/borrower_contract","../../../web/images/car_dashboard"]                      },                      "pic_2": {                          "explain": "車輛2",                          "type": "text",                          "options": "",                          "value": ["../../../web/images/car_dashboard","../../../web/images/reg_car_info"]                     }                }              }        }      }';      $pictures = json_decode($result,true);  //變成數組了    $picdata=array();    $layoutpic=['picinfo'=>[['pic_1','pic_2']]];    foreach($layoutpic as $key=>$kuai){        $datakuai=array();        $temp=$pictures['view'][$key];        foreach($kuai as $hang){            $datahang=array();            foreach($hang as $lie){                $a=$temp['data'];                $datahang[$a[$lie]['explain']]=$a[$lie]['value'];                // var_dump($datahang);                 // var_dump($a[$lie]['value']);            }            array_push($datakuai,$datahang);        }        $picdata[$temp['tag_name']]=$datakuai;      }    foreach ($picdata as $key => $value) {              foreach ($value as $key1 => $value1) {                   }    }       $smarty -> assign("mypicture1",$value1);

tpls模板:

 {foreach $mypicture1 as $a=>$b}    <div style="float:left; display:inline" class="infoblock mgt">      <h3 style="text-align:center">{$a}</h3>      <input type="image" src="{$b[0]}_small.jpg" data-toggle="modal" href="#{$a}">    </div>    <div class="container">    <div id="{$a}" class="modal fade">      <div class="modal-dialog">         <div class="modal-content">            <!-- 模態框 -->            <div id="{$a}myCarousel" class="carousel slide">               <!-- 輪播(Carousel)指標 -->               <ol class="carousel-indicators">                {foreach $b as $c}                  <li data-target="#{$a}myCarousel"></li>                {/foreach}               </ol>                 <!-- 輪播(Carousel)項目 -->               <div class="carousel-inner">                {foreach $b as $c}                  <div class="item active">                     <img src="{$c}_big.jpg">                     <div class="carousel-caption"></div>                  </div>                {/foreach}               </div>               <!-- 輪播(Carousel)導航 -->               <a class="left carousel-control" href="#{$a}myCarousel"               data-slide="prev">‹</a>               <a class="right carousel-control" href="#{$a}myCarousel"               data-slide="next">›</a>            </div>         </div>      </div>    </div>    {/foreach}


著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.