使用了wecms.cn的随机标签代码,为什么我的标签只展示8个以下。

kexuebin2021-12-22  913

 

<?php if ('mysql' == $conf['cache']['type']) {
   $taglist = well_tag_find(1, 500);
} else {
   $taglist = cache_get('well-taglist-random');
   if (NULL === $taglist) {
      $taglist = well_tag_find(1, 500);
      $taglist and cache_set('well-taglist-random', $taglist, 1800);
   }
}
?>
<?php if($taglist){
$tagkeys = array_keys($taglist);
$tagtotal = count($tagkeys) > 20 ? 20 : count($tagkeys);
$randkeys = count($tagkeys) > 20 ? array_rand($tagkeys, $tagtotal) : $tagkeys;
?>
<div class="card border-0 rounded shadow-sm mb-3">
    <div class="card-header border-0 rounded-top bg-white">
        <h3 class="h6 font-weight-400 my-0">
            热门标签
        </h3>
    </div>

    <ul class="list-unstyled right-font d-flex flex-wrap bg-white px-3 py-2 m-0">
        <!-- 循环输出 tag 开始 -->
        <?php foreach($taglist as $val) { ?>
        <?php if (!in_array($val['tagid'], $randkeys)) continue; ?>
        <li class="px-2 py-1 badge-pill badge-light right-tag mr-2 mb-2">
            <h4 class="h6 my-0">
                <!-- 链接和 tag -->
                <a href="<?php echo $val['url'];?>" class="d-block text-truncate right-font">
                    <?php echo $val['name'];?>
                </a>
            </h4>
        </li>
        <?php } ?>
        <!-- 循环输出 tag 结束 -->

    </ul>
</div>
<?php } ?>
转载请注明原文地址:https://www.wellcms.net/read-99.html
00
最新回复(2)