How does dede tag cloud generate tags?
How does dede tag cloud generate different colors and different Tag tags of different sizes
tag tag Friends who make websites must know it. In this article, I will explain to you the use of dede tag cloud and how to generate tag tags of different colors and sizes. Interested friends can refer to the following
Recommended learning: 梦Weavercms
1. Select the template of the page you want to add, usually add the following to the homepage index.htm Code
The code is as follows:
<!-- /下面开始tag标签云 --> <div> <dl class="tbox light"> <dt><strong>Tags标签云</strong></dt> <dd>{dede:tag row='45' getall='1' sort='hot'} <a href='[field:link/]' title="[field:tag /]([field:total /])" style="[field:total runphp=yes]@me=getTagStyle();[/field:total]">[field:tag /]</a> {/dede:tag} </dd> </dl> </div> <!-- /tag标签云结束 --> ***或(测试通过)*** <li> <div class="s_title"><h2>热门标签</h2></div> <div class="tagnews"> {dede:tag row='35' sort='month'} <a href='[field:link/]' title="[field:tag /]([field:total /])" style="[field:total runphp=yes]@me=getTagStyle();[/field:total]">[field:tag /]</a> {/dede:tag} </div> </li>
2. Add the following function to /include/common.func.php.
The code is as follows:
function getTagStyle() { $minFontSize=8; //最小字体大小,可根据需要自行更改 $maxFontSize=18; //最大字体大小,可根据需要自行更改 return 'font-size:'.($minFontSize+lcg_value()*(abs($maxFontSize-$minFontSize))).'px;color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255)); }
The function of this function is to output a random style, including font-size and color.
If you want to specify only a few font sizes to be displayed instead of completely random, please modify the above function code to:
The code is as follows:
function getTagStyle() { $sizearray = array('8','9','10','11','12','20'); //自定义字体大小,可根据需要自行修改 return 'font-size:'.$sizearray[rand(0,count($sizearray))].'pt;color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255)); }
3. Generate You can see the effect below!
Finally, let everyone take a look at the renderings: Renderings
The above is the detailed content of How to generate tag tags in dede tag cloud. For more information, please follow other related articles on the PHP Chinese website!