0

脚本说明是否有 1 个或 2 个脚本帖子的部分是双倍的。我只想要(如果有 1 或 2 篇文章)它只显示 1 或 2 篇文章

<?php
    defined('_JEXEC') or die;
    $count = 0;
    if (count($list)%3!=0) {
        $list = array_merge($list, array_slice($list, 0, 3-count($list)%3));
    }
    if (count($list)%2!=0) {
        $list = array_merge($list, array_slice($list, 0, 2-count($list)%2));
    }
    if (count($list)%1!=0) {
        $list = array_merge($list, array_slice($list, 0, 1-count($list)%1));
    }
?>

<?php JLoader::register('fieldattach', 'components/com_fieldsattach/helpers/fieldattach.php'); ?>

<div id="slides">
    <div class="slides_container">

        <div class='slide'>
            <?php foreach ($list as $item) :
                if (($count>0) and ($count%3==0)): ?>
                    </div>
                    <div class="slide">
                <?php endif; ?>

                <li class="categories">
                    <a href="<?php echo $item->link; ?>">
                        <?php echo fieldattach::getImg($item->id, 6); ?>
                        <h4><?php echo $item->title; ?></h4>
                    </a>
                </li>

            <?php $count++; endforeach; ?>
        </div>
    </div>
</div>
4

0 回答 0