//随机标签颜色
function tagsrandom(){
    $sjbg =array(
       "1" => "badge badge-pill blue",
       "2"=>"badge badge-pill red",
       "3"=>"badge badge-pill pink",
       "4"=>"badge badge-pill orange",
       "5"=>"badge badge-pill yellow",
       "6"=>"badge badge-pill green",
       "7"=>"badge badge-pill teal",
       "8"=>"badge badge-pill cyan",    
        );
        shuffle($sjbg);
        echo array_shift($sjbg);

}

在function插入上面的代码

在需要实现的地方放入以下代码

<div class="col-md-2 mx-auto">
            <h5 class="text-uppercase font-weight-bold mb-4">标 签 云</h5>
            <div class="footer-tags">

                <?php $this->widget('Widget_Metas_Tag_Cloud',array('limit' => 15))->to($tags);  ?>  
                <?php while($tags->next()): ?>  
                <li><a rel="tag" class="<?php tagsrandom();?>" href="<?php $tags->permalink(); ?>"><?php $tags->name(); ?></a></li>
                <?php endwhile; ?>
            </div>
        </div>

技术不佳 只会这样实现了,慢慢学习中,做个记录

然后样式的话需要自己写!这是个参考,当然你也可以直接扒我的~

其实我也不会前端 都是扒来的。

Last modification:March 18th, 2018 at 08:51 pm
如果觉得我的文章对你有用,请随意赞赏