여러게시판에서 최신글 원하는것만 뽑아오기 [갤러리 포함] > 그누4 팁자료실

그누4 팁자료실

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

여러게시판에서 최신글 원하는것만 뽑아오기 [갤러리 포함] 정보

여러게시판에서 최신글 원하는것만 뽑아오기 [갤러리 포함]

본문

아래 "엑스엠엘" 님의 팁에서 추가된 기능입니다.

현재 갤러리 최신글을 뽑아올때는 $bo_table 이 적용되지 않아 $wr_id값이 같은것일경우

같은 이미지가 나오실것입니다.

이 $bo_table 를 bn_id 로 대처합니다.

그리고 wr_x 처럼 여분필드명에서 특정데이터만 뽑아오도록 select 문에도 추가했습니다.

http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=62547

위 팁을 적용하신후

lib/latest.group.lib.php 파일을 아래내용으로 변경해주세요

궁금하신점은 코맨트 또는 http://ntype.kr 로 문의주세요 ^^

// 적용방법

<?=latest_group("simple", array( 'board02', 'board04', 'and_so_on'), 3, 27); ?>

wr_2 필드값이 1인것만 뽑아오도록 하였습니다.

// lib/latest.group.lib.php 수정
<?
if (!defined('_GNUBOARD_')) exit;
function quoting(&$item1, $key) { $item1 = "'$item1'"; }
// 최신글 추출
function latest_group( $skin_dir, $bo_tables, $rows=10, $subject_len="", $content_len="") {
    global $g4;
    if ($skin_dir) $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else $latest_skin_path = "$g4[path]/skin/latest/basic";
    $list = array();
    $rows2 = $rows * 2; // 비밀글을 제외할 때 rows가 부족할까봐 여유있게
    array_walk( $bo_tables , 'quoting');
    $bo_tables= implode( ',', $bo_tables);
    $sql = " select bo_table, wr_id, bn_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_2 = '1' and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";

// bn_id 추가
// wr_2 필드가 1일때
    $result = sql_query($sql);
    $j = 0;
    while ($row = sql_fetch_array($result)) {
        if ($j > $rows) break; // rows에 지정된거보다 많으면 loop를 중단. 비밀글이 많으면 rows보다 적은 열이 return됨 (그대로 오꼭?중요하죠)
        // 게시판 테이블
        $sql3 = " select * from $g4[board_table] where bo_table = '$row[bo_table]'";
        $board = sql_fetch($sql3);
        $tmp_write_table = $g4[write_prefix] . $row[bo_table];
        $sql2 = " select * from $tmp_write_table where wr_id = '$row[wr_id]' ";
        $row2 = sql_fetch($sql2);
        if (!strstr($row2[wr_option], "secret")) {
            $list[$j] = get_list($row2, $board, $latest_skin_path, $subject_len);
            $list[$j][bo_name] = $board[bo_subject];
            $j++;
        }
  $bn_id_str[] = $row['bn_id'];
    }
    $result4 = sql_fetch(" select gr_subject from $g4[group_table] where gr_id = '$gr_id' ");
    $skin_title = "$result4[gr_subject]";
    $skin_title_link = "?url=$g4[bbs_path]/new.php?gr_id=$gr_id";

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



g4_board_new 테이블에 wr_2 필드를 추가해주셔야 합니다.
phpmyadmin 을 이용해주세요

// bbs/write_update.php 수정

    // 새글 INSERT
    //sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime ) values ( '$bo_table', '$wr_id', '$wr_id', '$g4[time_ymdhis]' ) ");
    //sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '$bo_table', '$wr_id', '$wr_id', '$g4[time_ymdhis]', '$member[mb_id]' ) ");

    sql_query(" insert into $g4[board_new_table] ( bo_table, wr_id, wr_parent, bn_datetime, mb_id, wr_is_comment, gr_id , wr_2 ) values ( '$bo_table', '$wr_id', '$wr_id', '$g4[time_ymdhis]', '$member[mb_id]', '0', '$gr_id' , '$wr_2' ) ");  // $wr_2 추가
    // 새글에 my_datetime UPDATE
    sql_query(" update $g4[board_new_table] set my_datetime = '$g4[time_ymdhis]' where bo_table = '$bo_table' and wr_id = '$wr[wr_id]' "); 

추천
4
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로