我在將php代碼集成到我的HTML代碼中時遇到了一些問題!任何人都可以幫助或指引我正確的方向嗎?任何人都可以幫助我與PHP集成PHP?
這裏是我的HTML代碼:
<!-- Slider -->
<div class="carousel-inner cont-slider">
<div class="item active">
<img alt="" title="" src="http://placehold.it/600x400">
</div>
<div class="item">
<img alt="" title="" src="http://placehold.it/600x400">
</div>
<div class="item">
<img alt="" title="" src="http://placehold.it/600x400">
</div>
<div class="item">
<img alt="" title="" src="http://placehold.it/600x400">
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#article-photo-carousel">
<img alt="" src="http://placehold.it/250x180">
</li>
<li class="" data-slide-to="1" data-target="#article-photo-carousel">
<img alt="" src="http://placehold.it/250x180">
</li>
<li class="" data-slide-to="2" data-target="#article-photo-carousel">
<img alt="" src="http://placehold.it/250x180">
</li>
<li class="" data-slide-to="3" data-target="#article-photo-carousel">
<img alt="" src="http://placehold.it/250x180">
</li>
</ol>
</div>
我的PHP代碼是
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<div class="item"><img src="' . $image['image']['sizes']['large'] . '" /></div>';
}
}
?>
上面的代碼是與充當不同的幻燈片導航的縮略圖滑塊。
我已經試過以下:
<!--Slider-->
<div class="carousel-inner cont-slider">
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<div class="item"><img src="' . $image['image']['sizes']['large'] . '" /></div>';
}
}
?>
</div>
以上工作正常,但是它不添加活動類
那麼對於NAV指標我做了以下
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#article-photo-carousel">
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<img src="' . $image['image']['sizes']['large'] . '" />';
}
}
?>
</li>
<li class="" data-slide-to="1" data-target="#article-photo-carousel">
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<img src="' . $image['image']['sizes']['large'] . '" />';
}
}
?>
</li>
<li class="" data-slide-to="2" data-target="#article-photo-carousel">
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<img src="' . $image['image']['sizes']['large'] . '" />';
}
}
?>
</li>
<li class="" data-slide-to="3" data-target="#article-photo-carousel">
<?php
if ($images = get_field('images', $design_id)) {
foreach ($images as $image) {
echo '<img src="' . $image['image']['sizes']['large'] . '" />';
}
}
?>
</li>
上面的問題是,data-slide-to =「...」沒有得到添加。
如果有人可以幫忙,那將不勝感激!由於
'以上工作正常,但是它不添加活性class' - >因爲你沒有在你的代碼中的任何地方寫'active'? – Xatenev 2014-10-01 10:33:06
但是當然如果我添加活動,將應用活動狀態到所有幻燈片..? – user3615681 2014-10-01 10:39:52