萬盛學電腦網

 萬盛學電腦網 >> CMS教程 >> dedecms列表調用標簽及標簽隨機顏色

dedecms列表調用標簽及標簽隨機顏色

class="area"> /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}
copyright © 萬盛學電腦網 all rights reserved