3.0버전에서 최신글 카테고리 뽑기 정보
그누호환 3.0버전에서 최신글 카테고리 뽑기
본문
/**********************************************************************
* [lib/latest.lib.php]소스입니..... *
**********************************************************************/
<?
//==============================================================================
// 최신글 관련 함수
//==============================================================================
// 최신글 추출
function latest($skin_dir='', $bo_table, $rows=10, $len=40)
{
global $latest_skin, $cfg;
$tmp_latest_skin = $latest_skin;
// 스킨디렉토리값이 넘어왔다면
if ($skin_dir) {
$latest_skin = "./$cfg[bbs_dir]/skin/latest/$skin_dir";
}
$sql = " select * from $cfg[table_board] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
$table = "{$cfg[write_table_prefix]}{$bo_table}";
$sql = " select a.*, mb_open
from $table a
left join $cfg[table_member] b on (b.mb_id = a.mb_id)
where a.wr_comment = 0
order by a.wr_num, a.wr_datetime desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;
$list[$i][href] = "./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage], $row[mb_open]);
$list[$i][subject] = conv_subject($row[wr_subject], $len,"…");
$list[$i][content] = get_text($row[wr_content]);
$list[$i][date] = substr($row[wr_datetime],2,8);
$wr_id = $row[wr_id];
if ($bo[bo_use_category]) { //카테고리가 있다면
$show_category_begin = "";
$show_category_end = "";
} else { //카테고리가 없다면
$show_category_begin = "<!--";
$show_category_end = "-->";
}
$list[$i][ca_name] = $wr_id = ""; // 분류를 뽑을 때 사용
if ($row[wr_id]) {
$sql1 = " select ca_name from {$table}_cat where ca_id = '$row[ca_id]'";
$row1 = sql_fetch($sql1);
if ($row1[ca_name])
$list[$i][ca_name] = "[$row1[ca_name]]";
}
$list[$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
$list[$i][reply] = "";
if (strlen($row[wr_reply]) > 0) {
for ($k=0; $k<strlen($row[wr_reply]); $k++) {
$list[$i][reply] .= " ";
}
}
$list[$i][icon_reply] = "";
if ($list[$i][reply]) {
$list[$i][icon_reply] = "<img src='$latest_skin/icon_reply.gif' align='absmiddle'>";
}
for ($k=1; $k<=$cfg[file_count]; $k++) {
if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
}
}
for ($k=1; $k<=$cfg[link_count]; $k++) {
if ($row["wr_link".$k]) {
$link[$i]["link".$k] = set_http(get_text(cut_str($row["wr_link".$k], 255)));
$link[$i]["link_href".$k] = "./?doc=$cfg[bbs_dir]/gblink.php&$qstr&wr_id=$row[wr_id]&index=$k";
}
}
}
mysql_free_result($result);
include "$latest_skin/latest.skin.php";
$latest_skin = $tmp_latest_skin;
}
?>
/**********************************************************************
* [bbs/skin/basic/latest.skin.php]소스입니다..... *
**********************************************************************/
<table width=99% cellpadding=0 cellspacing=1>
<tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr class='subject subjectbg ht'><td colspan=2 align=center><a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table"?>'><?=$bo_subject?></a></td></tr>
<tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<? for ($i=0; $i<count($list); $i++) { ?>
<tr height=22>
<td><?=$show_category_begin?><?=$list[$i][ca_name]?><?=$show_category_end?><?=$list[$i][reply]?><?=$list[$i][icon_reply]?><?=$list[$i][icon_new]?><a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><?=$list[$i][subject]?></a> <?=$list[$i][commentcnt]?></td>
<td width=70 align=center><?=$list[$i][name]?></td>
</tr>
<? } ?>
<? if (count($list) == 0) { echo "<tr><td colspan=3 align=center height=50>자료가 없습니다.</td></tr>"; } ?>
</table>
* [lib/latest.lib.php]소스입니..... *
**********************************************************************/
<?
//==============================================================================
// 최신글 관련 함수
//==============================================================================
// 최신글 추출
function latest($skin_dir='', $bo_table, $rows=10, $len=40)
{
global $latest_skin, $cfg;
$tmp_latest_skin = $latest_skin;
// 스킨디렉토리값이 넘어왔다면
if ($skin_dir) {
$latest_skin = "./$cfg[bbs_dir]/skin/latest/$skin_dir";
}
$sql = " select * from $cfg[table_board] where bo_table = '$bo_table' ";
$bo = sql_fetch($sql);
$bo_subject = $bo[bo_subject];
$table = "{$cfg[write_table_prefix]}{$bo_table}";
$sql = " select a.*, mb_open
from $table a
left join $cfg[table_member] b on (b.mb_id = a.mb_id)
where a.wr_comment = 0
order by a.wr_num, a.wr_datetime desc limit 0, $rows ";
$result = sql_query($sql);
for ($i=0; $row = mysql_fetch_array($result); $i++) {
$list[$i] = $row;
$list[$i][href] = "./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id=$row[wr_id]";
// 코멘트 카운트
$list[$i][commentcnt] = "";
if ($row[wr_commentcnt] > 0) {
$list[$i][commentcnt] = "($row[wr_commentcnt])";
}
$list[$i][name] = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage], $row[mb_open]);
$list[$i][subject] = conv_subject($row[wr_subject], $len,"…");
$list[$i][content] = get_text($row[wr_content]);
$list[$i][date] = substr($row[wr_datetime],2,8);
$wr_id = $row[wr_id];
if ($bo[bo_use_category]) { //카테고리가 있다면
$show_category_begin = "";
$show_category_end = "";
} else { //카테고리가 없다면
$show_category_begin = "<!--";
$show_category_end = "-->";
}
$list[$i][ca_name] = $wr_id = ""; // 분류를 뽑을 때 사용
if ($row[wr_id]) {
$sql1 = " select ca_name from {$table}_cat where ca_id = '$row[ca_id]'";
$row1 = sql_fetch($sql1);
if ($row1[ca_name])
$list[$i][ca_name] = "[$row1[ca_name]]";
}
$list[$i][icon_new] = "";
if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
$list[$i][icon_new] = "<img src='$latest_skin/icon_new.gif' align=absmiddle> ";
}
$list[$i][reply] = "";
if (strlen($row[wr_reply]) > 0) {
for ($k=0; $k<strlen($row[wr_reply]); $k++) {
$list[$i][reply] .= " ";
}
}
$list[$i][icon_reply] = "";
if ($list[$i][reply]) {
$list[$i][icon_reply] = "<img src='$latest_skin/icon_reply.gif' align='absmiddle'>";
}
for ($k=1; $k<=$cfg[file_count]; $k++) {
if (@preg_match($cfg[image_extension], $row["wr_file".$k])) {
$list[$i]["file_image".$k] = "./data/file/$bo_table/" . $row["wr_file".$k];
}
}
for ($k=1; $k<=$cfg[link_count]; $k++) {
if ($row["wr_link".$k]) {
$link[$i]["link".$k] = set_http(get_text(cut_str($row["wr_link".$k], 255)));
$link[$i]["link_href".$k] = "./?doc=$cfg[bbs_dir]/gblink.php&$qstr&wr_id=$row[wr_id]&index=$k";
}
}
}
mysql_free_result($result);
include "$latest_skin/latest.skin.php";
$latest_skin = $tmp_latest_skin;
}
?>
/**********************************************************************
* [bbs/skin/basic/latest.skin.php]소스입니다..... *
**********************************************************************/
<table width=99% cellpadding=0 cellspacing=1>
<tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<tr class='subject subjectbg ht'><td colspan=2 align=center><a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table"?>'><?=$bo_subject?></a></td></tr>
<tr><td colspan=2 height=1 background='./<?=$cfg[bbs_dir]?>/line.gif'></td></tr>
<? for ($i=0; $i<count($list); $i++) { ?>
<tr height=22>
<td><?=$show_category_begin?><?=$list[$i][ca_name]?><?=$show_category_end?><?=$list[$i][reply]?><?=$list[$i][icon_reply]?><?=$list[$i][icon_new]?><a href='<?="./?doc=$cfg[bbs_dir]/gnuboard.php&bo_table=$bo_table&wr_id={$list[$i][wr_id]}"?>'><?=$list[$i][subject]?></a> <?=$list[$i][commentcnt]?></td>
<td width=70 align=center><?=$list[$i][name]?></td>
</tr>
<? } ?>
<? if (count($list) == 0) { echo "<tr><td colspan=3 align=center height=50>자료가 없습니다.</td></tr>"; } ?>
</table>
추천
0
0
댓글 전체
감사합니다. 잘 참고하겠습니다.
2.63 버전에도 가능하나요?
위의 팁을 적용하면 최신글에서 리플[답변]을 달면 리플이 표시됩니다.
우리아빠님//2.63버전에는 아마도 어려울듯 싶네요..... 그 이유는 출력의 구조가 많이 바뀌었어요.....*^^*
대신 위의 소스와 구버전을 비교하시면 해답이 있을 것입니다....*^^*
대신 위의 소스와 구버전을 비교하시면 해답이 있을 것입니다....*^^*
네 감사합니다 ^^
적용 했어요^^*
감솨
감솨