게시판에 특정 카테고리(분류) 등급별로 보이게 하기

게시판에 특정 카테고리(분류) 등급별로 보이게 하기

QA

게시판에 특정 카테고리(분류) 등급별로 보이게 하기

본문

안녕하세요.

 

"서울"이라는 게시판이 있고, "가", "나", "다" 라는 카테고리가 있다면

회원등급 5미만인 회원에게는 "가", "나" 카테고리명과 그에 속한 글만 보이고

회원등급 5이상인 회원에게는 "가", "나", "다" 카테고리명과 그에 속한 글 전부가 보이게 할려면 어덯게 해야 될까요

 

그누보드는 하면 할 수록 궁굼한게 많아지게 되네요 ^^

감사합니다

이 질문에 댓글 쓰기 :

답변 3

bbs\list.php 파일을 아래와 같이 수정해보세요


// 분류 사용 여부
$is_category = false;
$category_option = '';
if ($board['bo_use_category']) {
    $is_category = true;
    $category_href = G5_BBS_URL.'/board.php?bo_table='.$bo_table;
 
    $category_option .= '<li><a href="'.$category_href.'"';
    if ($sca=='')
        $category_option .= ' id="bo_cate_on"';
    $category_option .= '>전체</a></li>';
 
    $categories = explode('|', $board['bo_category_list']); // 구분자가 , 로 되어 있음
    if($member['mb_level']<5) {
        $key = array_search('다', $categories);
        array_splice( $categories, $key, 1 );
    }
    for ($i=0; $i<count($categories); $i++) {
        $category = trim($categories[$i]);
        if ($category=='') continue;
        $category_option .= '<li><a href="'.($category_href."&sca=".urlencode($category)).'"';
        $category_msg = '';
        if ($category==$sca) { // 현재 선택된 카테고리라면
            $category_option .= ' id="bo_cate_on"';
            $category_msg = '<span class="sound_only">열린 분류 </span>';
        }
        $category_option .= '>'.$category_msg.$category.'</a></li>';
    }
}
$incate = "'".implode("','",$categories)."'";
 
$sop = strtolower($sop);
if ($sop != 'and' && $sop != 'or')
    $sop = 'and';
 
// 분류 선택 또는 검색어가 있다면
$stx = trim($stx);
//검색인지 아닌지 구분하는 변수 초기화
$is_search_bbs = false;
 
if ($sca || $stx || $stx === '0') {     //검색이면
    $is_search_bbs = true;      //검색구분변수 true 지정
    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);
 
    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)
    $sql = " select MIN(wr_num) as min_wr_num from {$write_table} ";
    $row = sql_fetch($sql);
    $min_spt = (int)$row['min_wr_num'];
 
    if (!$spt) $spt = $min_spt;
 
    $sql_search .= " and (wr_num between {$spt} and ({$spt} + {$config['cf_search_part']})) ";
 
    // 원글만 얻는다. (코멘트의 내용도 검색하기 위함)
    // 라엘님 제안 코드로 대체 http://sir.kr/g5_bug/2922
    $sql = " SELECT COUNT(DISTINCT `wr_parent`) AS `cnt` FROM {$write_table} WHERE {$sql_search} ";
    $row = sql_fetch($sql);
    $total_count = $row['cnt'];
    /*
    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} ";
    $result = sql_query($sql);
    $total_count = sql_num_rows($result);
    */
    $sql_search .= " and ca_name in ($incate) ";
} else {
    $is_search_bbs = true; 
    $sql_search = " ca_name in ($incate) ";
 
    $total_count = $board['bo_count_write'];
}

https://www.delftstack.com/ko/howto/php/how-to-delete-an-element-from-an-array-in-php/
이 내용 참조하시고.. 아래 부분을 반복해서 추가해주면 됩니다.
        $key = array_search('다', $categories);
        array_splice( $categories, $key, 1 );

답변을 작성하시기 전에 로그인 해주세요.
전체 123,617 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT