지난주 게시글 TOP10 에서 공지랑 답변글은 빼고 싶습니다.
본문
코드는 아래와 같은데 공지랑 답변글은 제외 시키고 싶은데 어디를 수정해야 할까요?
<?php
// 지난주 게시글(조회순) TOP10 추출
function latest_top10($skin_dir="", $bo_table, $rows="", $subject_len="", $options="")
{
global $g4;
$where = "";
if ($bo_table) {
$sql = " select bo_subject, bo_new from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$bo_subject = $board["bo_subject"];
$bo_new = $board["bo_new"];
$more_link = $g4[bbs_path] ."/board.php?bo_table=". $bo_table;
$where = " and a.bo_table = '{$bo_table}' ";
}
else {
$bo_subject = "전체게시글";
$bo_new = 24;
$more_link = $g4[bbs_path] ."/new.php";
}
$list = array();
$sql = "select bo_table from $g4[board_table] where bo_use_search='1' ";
$result = sql_query($sql);
$usql = "";
while ($row = sql_fetch_array($result)) {
$write_table = $g4[write_prefix] . $row[bo_table];
$usql .= "(select '{$row[bo_table]}' as bo_table, wr_id, wr_subject, wr_comment, wr_name, wr_datetime, wr_is_phone, wr_hit as cnt ";
$usql .= "from $write_table where wr_is_comment = 0 ";
$usql .= "and DATE_FORMAT(wr_datetime, '%Y-%m-%d') BETWEEN curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY AND curdate() - INTERVAL DAYOFWEEK(curdate()) DAY limit 10) union ";
}
if ($usql) {
$usql = substr($usql, 0, strlen($usql)-6);
$result = sql_query($usql);
$total_count = mysql_num_rows($result);
$total_page = ceil($total_count / $rows);
$usql .= " order by cnt desc ";
$usql .= " limit $rows ";
$result = sql_query($usql);
$list = array();
for($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i] = $row;
$datetime = $row["wr_datetime"];
$datetime2 = substr($datetime,0,10);
if ($datetime2 == $g4[time_ymd])
$datetime2 = substr($datetime,11,5);
else
$datetime2 = substr($datetime,5,5);
$list[$i]["bn_datetime"] = $datetime2;
$list[$i]["bn_datetime2"] = $datetime;
$list[$i]["subject"] = conv_subject($row["wr_subject"], $subject_len, "…");
$list[$i]["wr_comment"] = $row["wr_comment"];
$list[$i]["iconf"] = "";
$row2 = sql_fetch(" select bf_type from $g4[board_file_table] where bo_table = '". $row["bo_table"] ."' and wr_id = '". $row["wr_id"] ."' order by bf_type desc limit 1 ");
if ($row2["bf_type"] != "") {
$list[$i]["iconf"] = $row2["bf_type"];
}
}
}
}
?>
!-->
답변 2
9줄의 내용을
$sql = " select bo_subject, bo_new from $g4[board_table] where bo_table = '$bo_table'" and wr_is_comment='0'; 이렇게 하면 코멘트는 제외되겠죠
공지글 제외라 ... 이거는 그누보드5에서는 g5_board 에서 관리하는 사항이라,
다른분이 답변을 기대해봅니다. ^^;;
g5_board 에서 bo_notice 필드 값을 확인해서 퀴리에서 제거하셔야 합니다.
공지 체크된 글의 wr_id 값이 , 로 분리되어 등록됩니다.
join 으로 해야할지 아니면 검색결과에서 if 문으로 해야할지 고민이 되겠네요.
답변을 작성하시기 전에 로그인 해주세요.