首页 > 运营 > 帮助中心 > 正文

织梦CMS 如何调用随机数

2020-01-27 17:30:38
字体:
来源:转载
供稿:网友

如何调用随机数

热点源码标签:

  1. {dede:tag row=120 sort=month}
  2. [field:tag/]
  3. {/dede:tag}

关键一点就是:

  1. class="tag[field:highlight /]"

再看它的css代码:

  1. #hotTag a.tag1 { color:#000000;font-weight:bold;}
  2. #hotTag a.tag2 { color:#e65730;text-decoration:underline;}
  3. #hotTag a.tag3 { color:#00b9da;font-weight:bold;}
  4. #hotTag a.tag4 { color:#FE3981;font-weight:bold;font-size:14px;}
  5. #hotTag a.tag5 { color:#669900;font-size:16px;}
  6. #hotTag a.tag6 { color:#660099;font-weight:bold;font-size:16px;}

只有数字随机,才会出现图示效果,因为他们的样式不一样的。

修改程序:

打开 include/tag.lib.php 文件,找到:

第一个:

  1. $row['highlight'] =0

修改为

  1. $row['highlight'] = mt_rand(1,6);

并把完整的IF语句注释掉,就是不要了。

  1. //if($row['monthcc']>1000 || $row['weekcc']>300 )
  2. // {
  3. // $row['highlight'] = mt_rand(3,4);
  4. // }
  5. // else if($row['count']>3000)
  6. // {
  7. // $row['highlight'] = mt_rand(5,6);
  8. // }
  9. // else
  10. //
  11. // $row['highlight'] = mt_rand(1,2);
  12. // }

当然可以调从多少到多少在$row['highlight'] = mt_rand(1,6); (开始,结束)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表