0

次のように動的にブートストラップ カルーセルを作成する必要があります。

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    etc...
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="someIMG.jpg" alt="...">

    </div>
    <div class="item">
      <img src="someIMG-nn.jpg" alt="...">

    </div>
    etc...
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
</div>

これで、動的にブートストラップ カルーセルを作成するために呼び出す osclass 関数ができました。

**<?php osc_run_hook('item_detail', osc_item() ) ; ?>
                    <?php if( osc_images_enabled_at_items() && (osc_count_item_resources() > 0) ) { ?>**

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
**<?php $i=0;?>**
                            **<?php while( osc_has_item_resources() ) { ?>**
    <li data-target="#carousel-example-generic" data-slide-to="**<?php echo $i; $i+1;?>**" class="active"></li>
    **<?php } ?>** 
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
**<?php while( osc_has_item_resources() ) { ?>**
    <div class="item">
      <img src="**<?php echo osc_resource_url(); ?>**" alt="...">


    </div>
    **<?php } ?>** 


  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>


</div>

私は初心者なので、ここで何が問題になるのかわかりません。私の論理では、私はうまく書いていると思いますが、私が書いたものはうまくいきません.

助けてください、私の英語でごめんなさい。ありがとう!

4

2 に答える 2

0

botstrap4 の場合、replace で動作します

<div class="carousel-item <?php echo ($i === 0) ? ' active': ''; ?>">
  <img src="<?php echo osc_resource_url(); ?>" alt="...">
</div>
于 2019-04-04T09:20:56.157 に答える