Home > CMS Tutorial > DEDECMS > body text

How to generate tag tags in dede tag cloud

藏色散人
Release: 2019-12-20 10:16:10
Original
2343 people have browsed it

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>
Copy after login

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)); 
}
Copy after login

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)); 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!