게시판 공지사항 체크해도 순서 바뀌지않게 채택완료

게시판에서 관리자로 글을 등록할때 공지사항을 체크하면 리스트페이지에서 최상단에 노출되고있습니다. 이것을 공지사항을 체크해도 순서는 바뀌지않고 공지사항아이콘만 노출되도록 변경하고싶은데, 어느부분을 수정해야하나요??

답변 2개

채택된 답변
+20 포인트

bbs/list.php 에서

Copy
if (!$is_search_bbs) {
    $arr_notice = explode(',', trim($board['bo_notice']));
    $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;

        $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;

        $i++;
        $notice_count++;

        if($notice_count >= $list_page_rows)
            break;
    }
}
 

주석처리 하세요

Copy
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;
}

여기도 주석처리하세요

Copy
if ($is_search_bbs) {
    $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 ";
    /*
    if(!empty($notice_array))
        $sql .= " and wr_id not in (".implode(', ', $notice_array).") ";
    */
    $sql .= " {$sql_order} limit {$from_record}, $page_rows ";
}

    if(!empty($notice_array))
        $sql .= " and wr_id not in (".implode(', ', $notice_array).") ";

부분도 주석처리하세요

그럼 공지사항이 상단으로 올라가지 않을겁니다.

그리고 난후에

Copy
while ($row = sql_fetch_array($result))
    {
        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
        if ($is_search_bbs)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        if (strstr($sfl, 'subject')) {
            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
        }
        $list[$i]['is_notice'] = false;
               
        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
        $list[$i]['num'] = $list_num - $k;

        $i++;
        $k++;
    }

이부분을

Copy
if($page_rows > 0) {
    $result = sql_query($sql);

    $k = 0;

    while ($row = sql_fetch_array($result))
    {
        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
        if ($is_search_bbs)
            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");

        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        if (strstr($sfl, 'subject')) {
            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);
        }
        $list[$i]['is_notice'] = false;
        
        $arr_notice = explode(',', trim($board['bo_notice']));
        for ($z=0;$z <= count($arr_notice);$z++){
            if ($list[$i]['wr_id'] == $arr_notice[$z])    $list[$i]['is_notice'] = true;
        }
        
        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;
        $list[$i]['num'] = $list_num - $k;

        $i++;
        $k++;
    }
}

로 공지글번호들만 is_notice true가 되도록 추가해주세요

그럼 리스트에서 상단으로 올라가지 않고 is_notice값은 가질수 있을겁니다.

완벽한 부분은 아니고 공지관련 눈에 띄는 부분만 수정한거라서

원하시는 모양이 나오는건 확인했는데 예상치못한 버그가 있을수 있습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

정말감사합니다! 원하던 기능이 잘 적용되었습니다.

한가지만 더 여쭙고싶은데, 작성해주신 답변대로 적용해보니 제품카테고리 전체보기에서는 방금등록한 제품이 보이지 않고있습니다. 해당 분류로 들어가야 방금등록한 제품이 맨앞에 있던에.. 이부분은 어떻게 수정하는것이 좋을까요?

댓글을 작성하려면 로그인이 필요합니다.

@정새싹 해당list.php부분은 게시판의 list에 영향을 주는 부분으로 상품LIST와는 관련이 없습니다..

다른부분을 확인해보셔야 할 것 같습니다. list.php 소스를 원복해보시고 다시한번 점검을 해보시기 바랍니다. 영카트 쇼핑쪽은 저도 소스를 본적이 별로 없어서 소스를 찾아봐야 알 수 있습니다..

해당이슈는 별개문제같은데 ...일단 원복해서 상태를 보시고 다시 질의를 해보시는게

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고