search
HomeCMS TutorialDEDECMSHow DEDECMS implements color tag cloud

How DEDECMS implements color tag cloud

How DEDECMS implements a color tag cloud

DEDECMS color tag cloud-implements tag (TAG) randomization Color and size

Function description:

Realize the effect of tag cloud, including tags with different colors and font sizes, etc. The color and font size are randomly displayed and can be changed code to control its scope.

Recommended learning: dedecms tutorial

Modification method:

1. Add the following function to /include/common.func.php.

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 random styles, 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:

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));  
}

2. Use the following code to call the tag in the template.

{dede:tag row='45' getall='1' sort='hot'}  
<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}

3. Generate the corresponding html in the background, OK, let’s see the effect.

The above is the detailed content of How DEDECMS implements color 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)