Dedecms simple implementation of tag cloud _ tag _ different colors _ different sizes

Source: Internet
Author: User
Select the template on which you want to add the following code to index.htm on the first page:

1. select the template on which you want to add the following code to index.htm on the first page.
The code is as follows:

Tags tag cloud
{Dede: tag row = '45' getall = '1' sort = 'Hot '}
[Field: tag/]
{/Dede: tag}


2. add the following functions to/include/common. func. php.

Function getTagStyle ()
{
$ MinFontSize = 8; // minimum font size, which can be changed as needed
$ MaxFontSize = 18; // maximum font size, which can be changed as needed
Return 'font-size :'. ($ minFontSize + lcg_value () * (abs ($ maxFontSize-$ minFontSize ))). 'px; color :#'. dechbx (rand (0,255 )). dechbx (rand (0,196 )). dechex (rand (0,255 ));
}

This function outputs random styles, including font-size and color.
If you want to specify only a few font sizes, instead of being completely random, change the above function code:

Function getTagStyle ()
{
$ Sizearray = array ('8', '9', '10', '11', '12', '20'); // customize the font size, can be modified as needed
Return 'font-size :'. $ sizearray [rand (0, count ($ sizearray)]. 'Pt; color :#'. dechbx (rand (0,255 )). dechbx (rand (0,196 )). dechex (rand (0,255 ));
}

3. generate the following to see the effect!
Finally, let's take a look:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.