공지글 출력순서 채택완료
공지사항으로 글을 등록하게 되면 글을 작성한 날짜 순서가 아닌 글 등록 순서대로 리스트되고 있는걸
등록순서가 아닌 날짜순서로 나오게하고싶습니다.
공지글을 수정했을시 수정된글을 맨 위로 올리고 싶습니다.
방법이없을까요?
bbs/list.php 파일
// 공지 처리 $arr_notice = explode(',', trim($board['bo_notice'])); if (!$stx) { $from_notice_idx = ($page - 1) * $page_rows; if($from_notice_idx < 0) $from_notice_idx = 0; $board_notice_count = count($arr_notice);
for ($k=0; $k<$board_notice_count; $k++) { if (trim($arr_notice[$k]) == '') continue;
$row = sql_fetch(" select * from {$write_table} where wr_id = '{$arr_notice[$k]}' ");
if (!$row['wr_id']) continue;
// 분류일 때 if($sca) { if($row['ca_name'] != '공지' && $sca != $row['ca_name']) continue; }
$notice_array[] = $row['wr_id'];
if($k < $from_notice_idx) continue;
$list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']); $list[$i]['is_notice'] = true; /*추가 시작*/ $notice_order .= " and wr_id != '$arr_notice[$k]'"; //[2008-02-03] 추가 /*추가 끝*/ $i++; $notice_count++;
if($notice_count >= $list_page_rows) break; } }
/*추가 시작*/ //분류선택시 전체페이지에서 공지사항의 갯수만큼 빼줌.[2008-02-03]//추가 if($min_spt) { $total_page = ceil($total_count / $board[bo_page_rows]); }else{ $total_page = ceil(($total_count - $bo_notics_cnt) / $board[bo_page_rows]); }
/*추가 끝*/ $total_page = ceil($total_count / $page_rows); // 전체 페이지 계산 $from_record = ($page - 1) * $page_rows; // 시작 열을 구함
// 공지글이 있으면 변수에 반영 if(!empty($notice_array)) { //$from_record -= count($notice_array);
if($from_record < 0) $from_record = 0;
//if($notice_count > 0) //$page_rows -= $notice_count;
if($page_rows < 0) $page_rows = $list_page_rows; }
// 관리자라면 CheckBox 보임 $is_checkbox = false; if ($is_admin) $is_checkbox = true;
// 정렬에 사용하는 QUERY_STRING $qstr2 = 'bo_table='.$bo_table.'&sop='.$sop; if($sca) $qstr2 .= '&sca='.urlencode($sca);
// 0 으로 나눌시 오류를 방지하기 위하여 값이 없으면 1 로 설정 $bo_gallery_cols = $board['bo_gallery_cols'] ? $board['bo_gallery_cols'] : 1; $td_width = (int)(100 / $bo_gallery_cols);
// 정렬 // 인덱스 필드가 아니면 정렬에 사용하지 않음 //if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) { if (!$sst) { if ($board['bo_sort_field']) { $sst = $board['bo_sort_field']; } else { $sst = "wr_num, wr_reply"; $sod = ""; } } else { // 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16) // 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요. // $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : ""; $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood|wr_comment|as_view|as_down|as_download|as_poll|as_update|wr_link1_hit|wr_link2_hit)$/i", $sst) ? $sst : ""; }
if(!$sst) $sst = "wr_num, wr_reply";
if ($sst) { $sql_order = " order by {$sql_apms_orderby} {$sst} {$sod} "; }
if ($sca || $stx) { $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows "; } else { $sql = " select * from {$write_table} where wr_is_comment = 0 $notice_order /*$notice_order 추가*/ {$sql_apms_where} "; if(!$is_notice_list && $notice_count) $sql .= " and wr_id not in (".implode(', ', $arr_notice).") "; $sql .= " {$sql_order} limit {$from_record}, $page_rows "; }
위 부분을 수정해주면될것같은데 도움좀 부탁드립니다.
답변 1개
공지 처리가 끝나는 부분 다음에서
$list[$i]를 다음과 같은 배열 처리를 해주시면 될 듯 합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인