Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of realizing Color label Cloud by DEDECMS

Shulou Source: shulou.com Published: 2022-06-02 04:51:55 10月02日 Update

Editor to share with you the method of realizing color tag cloud in DEDECMS. I hope you will gain a lot after reading this article. Let's discuss it together.

How to realize Color label Cloud with DEDECMS

DEDECMS Color label Cloud-realize label (TAG) random color and size

Function description:

To achieve the effect of tag cloud, including tags have different colors and font sizes, etc., colors and font sizes are randomly displayed, you can change the code to control its range.

Modify method:

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

Function getTagStyle () {$minFontSize=8; / / minimum font size, you can change $maxFontSize=18; / / maximum font size as needed, and you can change return 'font-size:'. ($minFontSize+lcg_value () * (abs ($maxFontSize-$minFontSize).' px;color:#'.dechex (rand (0255)) .dechex (rand (0196)) .dechex (rand (0255));}

The function is used to output random styles, including font-size and color.

If you want to specify that only a few font sizes are displayed instead of being completely random, change the above function code to:

Function getTagStyle () {$sizearray = array); / / Custom font size, you can modify return 'font-size:'.$ sizearray as needed.' pt;color:#'.dechex (rand (0255)) .dechex (rand (0196)) .dechex (rand (0255));}

2. Call the tag in the template with the following code.

{dede:tag row='45' getall='1' sort='hot'} [field:tag /] {/ dede:tag}

3. Generate the corresponding html,OK in the background, depending on the effect.

After reading this article, I believe you have a certain understanding of DEDECMS to achieve color label cloud, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

Tags: Label size font color method code function color effect article different maximum minimum middle use function function done more style template Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei NVidia MySQL Docker