pbootcms插件二次开发教程:怎么简单实现tags标签随机颜色和字体大小
本文将向您介绍如何在pbootCMS中简单实现Tags标签的随机排序。通过简单对pbootcms简单的二次开发,详细介绍Tags标签随机颜色和字体大小具体实现方法。
前言:
在内容管理系统中,对标签进行随机排序是一个非常常见的需求。pbootCMS是一款基于PHP语言的内容管理系统,它提供了丰富的插件接口,方便开发者进行二次开发。本文将向您介绍如何在pbootCMS中简单实现Tags标签的随机颜色和字体大小。

Tags标签随机颜色和字体大小具体实现方法:
1、找到“appshomecontrollerParserController.php”文件;
2、搜索字符串“// 解析内容tags”并找到pbootcms 解析tags标签的函数“public function parserContentTagsLabel($content)”;
3、大概在1830行左右,找到”foreach ($data as $value) { // 按条数循环“,并在下面的switch中增加如下代码:
case 'color':
$one_html = str_replace($matches2[0][$j], "color:rgb(".rand(0, 254)." ".rand(0, 255)." ".rand(0, 254).");", $one_html);
break;
case 'fs':
$one_html = str_replace($matches2[0][$j], "font-size:".rand(12, 24)."px;", $one_html);
break;
4、找开pbootcms模板文件,如”templatedefault_bakhtml ewslist.html“;
5、在相应位置调用tags标签,代码如下:(主要在pbootcms标签内增加了 style="[tags:color][tags:fs]")
{pboot:tags num=50 scode={sort:tcode}}
<a href="[tags:link]" style="[tags:color][tags:fs]">[tags:text]</a>
{/pboot:tags}至此,就完成了pbootcms tags标签颜色和字体随机的功能。