cloud extend 사용중입니다.
본문
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if ($is_mobile) {
//ver1.0 150608 @_untitle_d
//글꼴 크기 px
define('G5_SC_MAXSIZE', 22); //maxsize
define('G5_SC_MINSIZE', 12); //minsize
define('G5_SC_POP_CNT', 20); //검색어 몇개
define('G5_SC_DATE_CNT', 7); //몇일 동안
define('G5_SC_STYLE', '<div style="margin:0 auto;width:100%;padding:3px;text-align:left;">');
function search_cloud()
{
global $g5;
$pop_array = array();
$date_gap = date("Y-m-d", G5_SERVER_TIME - (60));
$sql = "select pp_word, count(*) as cnt from {$g5['popular_table']}
where pp_date between '$date_gap' and '".G5_TIME_YMD."'
group by pp_word
order by pp_id desc, pp_word
limit 0, ".G5_SC_POP_CNT;
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++){
$pop_array[$row[pp_word]] = $row[cnt];
}
return G5_SC_STYLE.tag_cloud($pop_array).'</div>';
}
//출처 https://youtu.be/iHxU6EAp6b4
function tag_cloud($tags)
{
$maxsize = G5_SC_MAXSIZE;
$minsize = G5_SC_MINSIZE;
$maxval = max(array_values($tags));
$minval = min(array_values($tags));
$spread = ($maxval - $minval);
$step = (($maxsize - $minsize) / $spread);
$str = '';
foreach($tags as $key => $value){
$size = round($minsize + (($value - $minval) * $step));
$str .= '<font size="2">【</font><a href="'.G5_BBS_URL.'/search.php?sfl=wr_subject&sop=and&stx='.urlencode($key).'" style="font-size:'.$size.'px">'.$key.'</a><font size="2">】</font> ';
}
return $str;
}
} else {
//ver1.0 150608 @_untitle_d
//글꼴 크기 px
define('G5_SC_MAXSIZE', 22); //maxsize
define('G5_SC_MINSIZE', 12); //minsize
define('G5_SC_POP_CNT', 55); //검색어 몇개
define('G5_SC_DATE_CNT', 7); //몇일 동안
define('G5_SC_STYLE', '<div style="margin:0 auto;width:100%;padding:3px;text-align:left;">');
function search_cloud()
{
global $g5;
$pop_array = array();
$date_gap = date("Y-m-d", G5_SERVER_TIME - (60));
$sql = "select pp_word, count(*) as cnt from {$g5['popular_table']}
where pp_date between '$date_gap' and '".G5_TIME_YMD."'
group by pp_word
order by pp_id desc, pp_word
limit 0, ".G5_SC_POP_CNT;
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++){
$pop_array[$row[pp_word]] = $row[cnt];
}
return G5_SC_STYLE.tag_cloud($pop_array).'</div>';
}
//출처 https://youtu.be/iHxU6EAp6b4
function tag_cloud($tags)
{
$maxsize = G5_SC_MAXSIZE;
$minsize = G5_SC_MINSIZE;
$maxval = max(array_values($tags));
$minval = min(array_values($tags));
$spread = ($maxval - $minval);
$step = (($maxsize - $minsize) / $spread);
$str = '';
foreach($tags as $key => $value){
$size = round($minsize + (($value - $minval) * $step));
$str .= '<font size="2">【</font><a href="'.G5_BBS_URL.'/search.php?sfl=wr_subject&sop=and&stx='.urlencode($key).'" style="font-size:'.$size.'px">'.$key.'</a><font size="2">】</font> ';
}
return $str;
}
}
?>
이게 코드인데요. 여기서 인기 있는 키워드들은 font size가 바뀌도록 되어 있습니다. 그걸 색깔별로 바뀌도록 하려면 어떻게 수정해야 할까요?
답변 1
style="font-size:'.$size.'px"
부분에서
style="font-size:'.$size.'px;color:red'"
식으로 원하는 컬러로 바꿔주시면 되겠네요.
!-->!-->