致力于打造中国站长娱乐学习的免费资源站!官方合作QQ:283852481

广

您当前的位置:首页 > 教程 > CMS教程 > DEDECMS

招租联系QQ:283852481

dedecms列表调用标签及标签随机颜色

时间:2016-10-22  来源:互联网  

/include/common.func.php
/tag随机颜色
//function getTagStyle() {
//$sizearray = array('10','12'); //自定义字体大小,可根据需要自行修改
//$sizearray2 = array('FE9901','68B338'); //自定义背景颜色
//return 'font-size:'.$sizearray[rand(0,count($sizearray))].'pt;color:#'.dechex(rand(0,255)).dechex(rand(0,196)).dechex(rand(0,255)).';background:#'.$sizearray2[rand(0,count($sizearray2))];
//}
function getTagStyle() {
$sizearray = array('style01','style02','style03','style04'); //自定义字体大小,可根据需要自行修改
return $sizearray[rand(0,count($sizearray))];
}
//列表调用tag标签
function listtag($aid)   {       $tsql = new DedeSql(false);       $tags = '';       $tsql->SetQuery("Select i.tag From dede_taglist t left join dede_tagindex i on i.id=t.tid where t.aid='$aid'");       $tsql->Execute('t');       while($row = $tsql->GetArray('t',MYSQL_ASSOC)){          $tags .= "<a title='{$row['tag']}' href='/tags.php?/".urlencode($row['tag'])."/'>".$row['tag']."</a> ";       }       return $tags;   }
调用:[field:id function="listtag(@me)"/]
标签颜色:{dede:tag row='25' getall='1' sort='rand'}
<a href="[field:link/]" title="[field:tag /]" class="[field:total runphp=yes]@me=getTagStyle();[/field:total]">[field:tag /]</a>
{/dede:tag}

精彩广告