여러 게시판 대상으로 공지글만 모으다...... > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

여러 게시판 대상으로 공지글만 모으다...... 정보

여러 게시판 대상으로 공지글만 모으다......

본문

여러 게시판 대상으로 공지글만 모으다 말았습니다.

$rows에서 지정된 수가 차면 loop를 멈춥니다.
순서 지정 기능 없습니다.

이 부분은

http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=15413&page=2

참고하세요.


2008.06.02 코드 일부 수정:
    while( $row= sql_fetch_array( $notice_res)) {
        $this_notice= trim($row['bo_notice']);
        if( empty( $this_notice)) continue;
        $notice_wr_id_cond[]= implode( ',', split("\n", $this_notice));
        $notice_bo_tables[]= $row['bo_table'];
    }


mysql은 union이 지원되어야 합니다.
제목과 첨부 파일을 가져옵니다. 필요한 것이 있으면 select에서 항목 추가해 주세요.
테스트 안 해 봤습니다. 양해 바랍니다.
지금 작업하는 mysql 버젼이 3점대네요.

사용법은 일반 latest()와 비슷합니다.


for( sql_fetch_array())에서 버그 수정
get_list( $board 변수 추가)

<?php echo latest_notice( 'basic', array( 'a','b','c'), 10, 50); ?>


lib/latest_notice.php
<?php
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function quoting(&$item1, $key) { $item1 = "'$item1'"; }
function latest_notice($skin_dir="", $bo_tables, $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";

    if( !is_array( $bo_tables)) return 'A second parameter error:bo_tables should be an array.';

    array_walk( $bo_tables , 'quoting');
    $bo_tables_cond= implode(',', $bo_tables);
    $notice_res= sql_query( "select bo_table, bo_notice from {$g4['board_table']} where bo_table in ( $bo_tables_cond ) " );

    $notice_wr_id_cond=array();
    $notice_bo_tables=array();

    while( $row= sql_fetch_array( $notice_res)) {
        $this_notice= trim($row['bo_notice']);
        if( empty( $this_notice)) continue;
        $notice_wr_id_cond[]= implode( ',', split("\n", $this_notice));
        $notice_bo_tables[]= $row['bo_table'];
    }

    $sqls= array();

    foreach( $notice_bo_tables as $idx => $notice_bo_table) {
        $sqls[]= " select wr_id , wr_subject from {$g4['write_prefix']}$notice_bo_table where wr_id in ( {$notice_wr_id_cond[$idx]} )";
    }

    $list = array();

    $result = sql_query( implode( ' union all ', $sqls));
    for ($i=0; ($row = sql_fetch_array($result)) && $i < $rows; $i++)
        $list[$i] = get_list($row, array( 'bo_table'=>$notice_bo_table), $latest_skin_path, $subject_len);

    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>

추천
5

댓글 5개

이번 것은 mysql v3.x 지원하는 것으로 바꾸었습니다.


<?php
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function quoting(&$item1, $key) { $item1 = "'$item1'"; }
function latest_notice($skin_dir="", $bo_tables, $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";

    if( !is_array( $bo_tables)) return 'A second parameter error:bo_tables should be an array.';

    array_walk( $bo_tables , 'quoting');
    $bo_tables_cond= implode(',', $bo_tables);
    $notice_res= sql_query( "select bo_table, bo_notice from {$g4['board_table']} where bo_table in ( $bo_tables_cond ) " );

    $notice_wr_id_cond=array();
    $notice_bo_tables=array();

    while( $row= sql_fetch_array( $notice_res)) {
        $this_notice= trim($row['bo_notice']);
        if( empty( $this_notice)) continue;
        $notice_wr_id_cond[]= implode( ',', split("\n", $this_notice));
        $notice_bo_tables[]= $row['bo_table'];
    }

    $list = array();
    $i=0;
    foreach( $notice_bo_tables as $idx => $notice_bo_table) {
        $sql= " select wr_id, wr_subject from {$g4['write_prefix']}$notice_bo_table where wr_id in ( {$notice_wr_id_cond[$idx]} )";

        for( $result= sql_query( $sql) ; ($row = sql_fetch_array($result)) && $i < $rows; $i++) {
            $list[$i] = get_list($row, array('bo_table'=>$notice_bo_table), $latest_skin_path, $subject_len);
        }
    }
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
전체 5 |RSS
그누4 팁자료실 내용 검색
  • 개별 목록 구성 번호 제목 작성자 작성일 추천 조회
  • 게시물이 없습니다.

회원로그인

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