Home  >  Article  >  CMS Tutorial  >  How to generate tag tags in dede tag cloud

How to generate tag tags in dede tag cloud

藏色散人
藏色散人Original
2019-12-20 10:16:102311browse

How to generate tag tags in dede tag cloud

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=&#39;45&#39; getall=&#39;1&#39; sort=&#39;hot&#39;} 
<a href=&#39;[field:link/]&#39; 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=&#39;35&#39; sort=&#39;month&#39;} 
<a href=&#39;[field:link/]&#39; 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 &#39;font-size:&#39;.($minFontSize+lcg_value()*(abs($maxFontSize-$minFontSize))).&#39;px;color:#&#39;.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(&#39;8&#39;,&#39;9&#39;,&#39;10&#39;,&#39;11&#39;,&#39;12&#39;,&#39;20&#39;); //自定义字体大小,可根据需要自行修改 
return &#39;font-size:&#39;.$sizearray[rand(0,count($sizearray))].&#39;pt;color:#&#39;.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

How to generate tag tags in dede tag cloud

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn