최신글에서 공지 글 먼저, 일반 글 나중 정보
최신글에서 공지 글 먼저, 일반 글 나중
첨부파일
본문
관련 글을 찾다 찾다, 힘들어서 만들어봤습니다.
짜맞추고, 편법쓰고, 머리굴리고,. 만들자 마자 기분좋아서 올리는거라,
소스 정리가 약간 덜 되있는편입니다.
공지글을 먼저 select시켜서 올리고, 그 공지글의 갯수를 rows에서 빼서,
뺀갯수만큼 일반글이 추출되도록 다시 select 시켜서.. 편법을 좀 썼습니다.
추천
3
3
댓글 5개
찾고있던 것입니다..^^ 감사합니다.
제가 잘못한건가염 .왜 적용이 안될까염..똑같아요 테스트해도 ㅠ.ㅠ 경로에 업로드시켰는뎀..
글구 lib꺼는 추가로 넣었는뎀..왜 안되졍 흑흑
글구 lib꺼는 추가로 넣었는뎀..왜 안되졍 흑흑
latest.lib.php 소스 수정을 봤습니다.
$list 에 데이타 들어가게 했어요.
============================================================
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " or ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id=$arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
//$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$count = " select count(*) as cnt from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
$cnt = sql_fetch($count);
$total = $rows - $cnt[cnt];
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " and ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id != $arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
$sql_common = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $total ";
$result = sql_query($sql_common);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[($i+$cnt[cnt])] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
$list 에 데이타 들어가게 했어요.
============================================================
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " or ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id=$arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
//$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
$count = " select count(*) as cnt from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $rows ";
$cnt = sql_fetch($count);
$total = $rows - $cnt[cnt];
$sql_notice = "";
for($i=0;$i<count($arr_notice);$i++){
if($i != 0){
$sql_notice .= " and ";
}
$arr_notice[$i] = trim($arr_notice[$i]);
if (strlen($arr_notice[$i]) > 0) $sql_notice .= "wr_id != $arr_notice[$i]";
}
if (strlen($sql_notice) > 0) $sql_notice = " and ( " . $sql_notice . ") ";
$sql_common = " select * from $tmp_write_table where wr_is_comment = 0 $sql_notice order by wr_num limit 0, $total ";
$result = sql_query($sql_common);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[($i+$cnt[cnt])] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

/lib/latest.lib.php 공지 최신글 추출하기
// 공지 최신글 추출
function latest_notice($skin_dir="", $bo_table, $rows=5, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$i = 0;
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
for ($k=0; $k<$rows; $k++)
{
if (trim($arr_notice[$k])=='') continue;
$row = sql_fetch(" select * from $tmp_write_table where wr_id = '$arr_notice[$k]' ");
if (!$row[wr_id]) continue;
$list[$i] = get_list($row, $board, $board_skin_path, $subject_len);
$list[$i][is_notice] = true;
$i++;
}
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
// 공지 최신글 추출
function latest_notice($skin_dir="", $bo_table, $rows=5, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$i = 0;
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$arr_notice = split("\n", trim($board[bo_notice]));
for ($k=0; $k<$rows; $k++)
{
if (trim($arr_notice[$k])=='') continue;
$row = sql_fetch(" select * from $tmp_write_table where wr_id = '$arr_notice[$k]' ");
if (!$row[wr_id]) continue;
$list[$i] = get_list($row, $board, $board_skin_path, $subject_len);
$list[$i][is_notice] = true;
$i++;
}
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
한번해봐야겠네요....몇일째 찾아헤매고있음...ㅠㅠ