doubinchou4219 2017-06-23 11:58
浏览 137
已采纳

forest数据在bootstrap滑块上显示行中的数据

This is code for image slider with little bit text on image. This code showing images in a rows. But I want to make it slider. So, please help me.

                  <?php $isFirst = true; ?>
                  <?php foreach ($summaries as $key => $Summary){  ?>
                      <div class="item{{{ $isFirst ? ' active' : '' }}}">
                        <?php
                            if($Image){ 
                          ?>
                            <?= $this->Html->image('../img/'.$Image[0]['Image']['name'],array('class' =>"img-responsive imgslider"));  ?>
                        <?php } else{ ?>
                            <?= $this->Html->image('new_dummy.png',array('class'=>'img-responsive imgslider')); ?>
                        <?php }; ?>
                        <div class="carousel-caption" style="background:rgba(0,0,0,0.5)">
                          <h3><?= $Summary['Summary']['dhalao_id']?  $Summary['Dhalao']['name'] : 'Root'; ?></h3>
                          <p>Quantity Report: <?= $Summary['Summary']['time_created'] ;?> && Time: <?= $Summary['Summary']['date_created']; ?></p>
                        </div>
                      </div>
                  <?php $isFirst = false; ?>
                  <?php }; ?>

Here, I created $isFirst variable, what stays true until first slide has been printed. This way we can add active class for first slide and not for others.

  • 写回答

2条回答 默认 最新

  • douyue7408 2017-06-23 12:11
    关注

    please use default format of php. start with tag in line

     <div class="item{{{ $isFirst ? ' active' : '' }}}">
    

    and apply condition like following:

    <div class="item <?php echo ($isFirst) ? ' active' : '' ; ?>">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误