추가 화면
본 소스는 예쁜스킨을 여럿 배포한 jeolee님의 '24시간 내의 코멘트에 newicon을 달아보자' ' 포스트에서 공개한 소스에 기초를 두고 있다. 0.92시절에 공개한 소스라 0.93에서는 파일구조와 함수가 변동되어 작동하지 않아 재수정하여 다시 추가방법을 소개한다.
그리고 코멘트 뿐만아니라 트랙백 리스트에도 적용 하는 방법을 함께 포함한다. 자, 이제부터 태터에 New아이콘을 달아보자. 잠깐! 백업은 필수!!
편집대상 파일 3개 : inc_function.php, inc_presswork.php, skin.html
아이콘 다운로드 :
new.gif (59 Byte)
new2.gif (59 Byte)
inc_function.php : 아이콘 이미지와 시간을 지정해주는 함수이다. get_timevalue5에서 코멘트 아이콘이 표시될 시간은 12시간, 아이콘 이미지를 정의하고 get_timevalue6에서 트랙백 아이콘이 표시될 시간은 24시간, 아이콘 이미지는 서로 다르게 정의 했다. 이미지는 tt/images 폴더 (skin/../images 아님)에 업로드한다. 시간은 초단위로 계산하여 줄이거나 늘릴 수 있다.
코드를 추가 할 곳은 파일을 편집하지 않았다면 266라인이다. 이미 건드렸다면 문자열 검색으로 찾아보자.
코드닫기..
추가전 :
function get_timevalue4($date) {
return date("Y/m/d-H:i:s", $date);
}
// 이곳에 코드 추가
function autolink($str) {
추가후 :
function get_timevalue4($date) {
return date("Y/m/d-H:i:s", $date);
}
function get_timevalue5($val) {
$todaytime = time() - 43200; // 표시될 시간 - 초단위(12시간)
$newicon = "<img src=./images/new2.gif valign=absmiddle>"; //코멘트에 사용될 아이콘 이미지
if ($todaytime < $val) return $newicon;
else return "";
}
function get_timevalue6($val) {
$todaytime = time() - 86400; // 표시될 시간 - 초단위(24시간)
$newicon = "<img src=./images/new.gif valign=absmiddle>"; //트랙백 사용될 아이콘 이미지
if ($todaytime < $val) return $newicon;
else return "";
}
function autolink($str) {
inc_presswork.php : 코멘트 리스트와 트랙백 리스트에 치환자를 정의한다. 121열 부근에엤는 get_rcttb_rep()와 get_rctrp_rep()에 지정된 함수에 아래 처럼 한줄씩 추가한다.
코드닫기..
추가전 :
function get_rcttb_rep() {
global $db, $dbid, $p_rct_tb_cnt, $p_rct_tb_trunc;
unset($p);
$sql = "select no, pno, site, url, title, body, regdate, ip from t3_".$dbid."_trackback order by no desc limit 0, $p_rct_tb_cnt";
//print $sql;
$result = @mysql_query($sql);
while(list($no, $pno, $site, $url, $title, $body, $regdate, $ip) = @mysql_fetch_array($result)) {
$p_rep = $GLOBALS["skin"]->s_rcttb_rep;
$p_rep = str_replace("[##_rcttb_rep_link_##]", "index.php?pl=$pno#t$no", $p_rep);
$p_rep = str_replace("[##_rcttb_rep_desc_##]", str_cut($title,$p_rct_tb_trunc,0), $p_rep);
$p_rep = str_replace("[##_rcttb_rep_name_##]", $site, $p_rep);
$p_rep = str_replace("[##_rcttb_rep_time_##]", get_timevalue0($regdate, 2), $p_rep);
$p .= $p_rep;
}
return $p;
}
function get_rctrp_rep() {
global $db, $dbid, $p_rct_rp_cnt, $p_rct_rp_trunc;
unset($p);
$sql = "select no, pno, name, body, regdate from t3_".$dbid."_reply order by no desc limit 0, $p_rct_rp_cnt";
// print $sql;
$result = @mysql_query($sql);
while(list($no, $pno, $name, $body, $regdate) = @mysql_fetch_array($result)) {
$p_rep = $GLOBALS["skin"]->s_rctrp_rep;
$p_rep = str_replace("[##_rctrp_rep_link_##]", "index.php?pl=$pno#r$no", $p_rep);
$p_rep = str_replace("[##_rctrp_rep_desc_##]", str_cut($body, $p_rct_rp_trunc, 0), $p_rep);
$p_rep = str_replace("[##_rctrp_rep_name_##]", $name, $p_rep);
$p_rep = str_replace("[##_rctrp_rep_time_##]", get_timevalue0($regdate, 2), $p_rep);
$p .= $p_rep;
}
return $p;
}
function get_rctps_rep() {
global $db, $dbid, $is_public, $p_rct_ps_cnt, $p_rct_ps_trunc;
unset($p);
$sql = "select no, title, rp_cnt from t3_".$dbid." where $is_public order by regdate desc limit 0, $p_rct_ps_cnt";
// print $sql;
$result = @mysql_query($sql);
while(list($no, $title, $rp_cnt) = @mysql_fetch_array($result)) {
if ($rp_cnt) $rp_cnt = "($rp_cnt)"; else $rp_cnt = "";
$p_rep = $GLOBALS["skin"]->s_rctps_rep;
$p_rep = str_replace("[##_rctps_rep_link_##]", "index.php?pl=$no", $p_rep);
$p_rep = str_replace("[##_rctps_rep_title_##]", str_cut($title, $p_rct_ps_trunc, 1), $p_rep);
$p_rep = str_replace("[##_rctps_rep_rp_cnt_##]", $rp_cnt, $p_rep);
$p .= $p_rep;
}
return $p;
}
추가후 :
function get_rcttb_rep() {
global $db, $dbid, $p_rct_tb_cnt, $p_rct_tb_trunc;
unset($p);
$sql = "select no, pno, site, url, title, body, regdate, ip from t3_".$dbid."_trackback order by no desc limit 0, $p_rct_tb_cnt";
//print $sql;
$result = @mysql_query($sql);
while(list($no, $pno, $site, $url, $title, $body, $regdate, $ip) = @mysql_fetch_array($result)) {
$p_rep = $GLOBALS["skin"]->s_rcttb_rep;
$p_rep = str_replace("[##_rcttb_rep_link_##]", "index.php?pl=$pno#t$no", $p_rep);
$p_rep = str_replace("[##_rcttb_rep_desc_##]", str_cut($title,$p_rct_tb_trunc,0), $p_rep);
$p_rep = str_replace("[##_rcttb_rep_name_##]", $site, $p_rep);
$p_rep = str_replace("[##_rcttb_rep_time_##]", get_timevalue0($regdate, 2), $p_rep);
$p_rep = str_replace("[##_rcttb_rep_timeicon_##]", get_timevalue6($regdate), $p_rep); // 트랙백 new 아이콘
$p .= $p_rep;
}
return $p;
}
function get_rctrp_rep() {
global $db, $dbid, $p_rct_rp_cnt, $p_rct_rp_trunc;
unset($p);
$sql = "select no, pno, name, body, regdate from t3_".$dbid."_reply order by no desc limit 0, $p_rct_rp_cnt";
// print $sql;
$result = @mysql_query($sql);
while(list($no, $pno, $name, $body, $regdate) = @mysql_fetch_array($result)) {
$p_rep = $GLOBALS["skin"]->s_rctrp_rep;
$p_rep = str_replace("[##_rctrp_rep_link_##]", "index.php?pl=$pno#r$no", $p_rep);
$p_rep = str_replace("[##_rctrp_rep_desc_##]", str_cut($body, $p_rct_rp_trunc, 0), $p_rep);
$p_rep = str_replace("[##_rctrp_rep_name_##]", $name, $p_rep);
$p_rep = str_replace("[##_rctrp_rep_time_##]", get_timevalue0($regdate, 2), $p_rep);
$p_rep = str_replace("[##_rctrp_rep_timeicon_##]", get_timevalue5($regdate), $p_rep); // 코멘트 new 아이콘
$p .= $p_rep;
}
return $p;
}
function get_rctps_rep() {
global $db, $dbid, $is_public, $p_rct_ps_cnt, $p_rct_ps_trunc;
unset($p);
$sql = "select no, title, rp_cnt, regdate from t3_".$dbid." where $is_public order by regdate desc limit 0, $p_rct_ps_cnt";
// print $sql;
$result = @mysql_query($sql);
while(list($no, $title, $rp_cnt, $regdate) = @mysql_fetch_array($result)) {
if ($rp_cnt) $rp_cnt = "($rp_cnt)"; else $rp_cnt = "";
$p_rep = $GLOBALS["skin"]->s_rctps_rep;
$p_rep = str_replace("[##_rctps_rep_link_##]", "index.php?pl=$no", $p_rep);
$p_rep = str_replace("[##_rctps_rep_title_##]", str_cut($title, $p_rct_ps_trunc, 1), $p_rep);
$p_rep = str_replace("[##_rctps_rep_rp_cnt_##]", $rp_cnt, $p_rep);
$p_rep = str_replace("[##_rctps_rep_timeicon_##]", get_timevalue6($regdate), $p_rep); // 새포스트 new 아이콘
$p .= $p_rep;
}
return $p;
}
skin.html : 추가된 치환자를 스킨의 적절한 위치에 적용하면 된다. 스킨마다 코드가 다르므로 본가에 적용된 스킨의 예를 든다. 265열 부근을 보면 아래와 같은 치환자들이 있을 것이다. 여기에 아이콘 치환자를 삽입해 보자.
코드닫기..
추가전 :
<div class='menu_bar'>Recent Posts</div>
<s_rctps_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rctps_rep_link_##]">[##_rctps_rep_title_##]</a> [##_rctps_rep_rp_cnt_##]</div>
</s_rctps_rep>
<p>
<div class='menu_bar'>Recent Comments</div>
<s_rctrp_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rctrp_rep_link_##]">[##_rctrp_rep_desc_##]</a> -[##_rctrp_rep_time_##]</div>
</s_rctrp_rep>
<p>
<div class='menu_bar'>Recent Trackbacks</div>
<s_rcttb_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rcttb_rep_link_##]">[##_rcttb_rep_desc_##]</a> -[##_rcttb_rep_time_##]</div>
</s_rcttb_rep>
<p>
추가후 :
<div class='menu_bar'>Recent Posts</div>
<s_rctps_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rctps_rep_link_##]">[##_rctps_rep_title_##]</a> [##_rctps_rep_rp_cnt_##] [##_rctps_rep_timeicon_##] </div>
</s_rctps_rep>
<p>
<div class='menu_bar'>Recent Comments</div>
<s_rctrp_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rctrp_rep_link_##]">[##_rctrp_rep_desc_##]</a> -[##_rctrp_rep_time_##] [##_rctrp_rep_timeicon_##] </div>
</s_rctrp_rep>
<p>
<div class='menu_bar'>Recent Trackbacks</div>
<s_rcttb_rep>
<div class='recent_text'><b>ㆍ</b><a href="[##_rcttb_rep_link_##]">[##_rcttb_rep_desc_##]</a> -[##_rcttb_rep_time_##] [##_rcttb_rep_timeicon_##] </div>
</s_rcttb_rep>
<p>
자~ 이제끝났다. 잘 작동 되는지 확인해보자. 코드에 밝은 분들은 쉽게 다른 리스트 들에도 응용하여 다이나믹한 블로그를 꾸밀 수 있을 것이다.
관련 포스트 :
태터 0.93 휘젓기! (기능추가 채크 리스트)
24시간 내의 코멘트에 newicon을 달아보자
덧글 #1 : 최근글 리스트에도 New icon을 적용하도록 수정 04/09/17, 08:13
Read 63,205 times, Like what you read?
Comments