여러 게시판을 대상으로 최신글 뽑아 오기 > 그누4 팁자료실

그누4 팁자료실

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

여러 게시판을 대상으로 최신글 뽑아 오기 정보

여러 게시판을 대상으로 최신글 뽑아 오기

본문

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

설치 방법은 위 게시물을 참고하세요.

댓 글 소스를 위 게시물에 있는 파일과 바꾸시거나 내용을 수정하시면 됩니다.

사용법은


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

게시판 아이디 갯수는 array() 함수에 원하시는 만큼 쓰세요.
추천
9

댓글 19개

<?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 from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";
    $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++;
        }
    }

    $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;
}
?>
엑스엠엘님의 공유정신에 감동스럽습니다. 엑스엠엘님같은 분의 활동으로 그누보드가 크게 발전하고 나아가 인터넷의 정보소통에 크게 기여하리라 믿습니다.
최신글에 [게시판제목]게시글제목 이렇게 나오게하고싶은데
$list[$j][bo_name] = $board[bo_subject];  이게 무슨뜻인지 모르겠어요
ㅠㅠ 아시는분없나요?
mysql> desc g4_board_new;
+-------------+-------------+------+-----+---------------------+----------------+
| Field      | Type        | Null | Key | Default            | Extra          |
+-------------+-------------+------+-----+---------------------+----------------+
| bn_id      | int(11)    | NO  | PRI | NULL                | auto_increment |
| bo_table    | varchar(20) | NO  |    |                    |                |
| wr_id      | int(11)    | NO  |    | 0                  |                |
| wr_parent  | int(11)    | NO  |    | 0                  |                |
| bn_datetime | datetime    | NO  |    | 0000-00-00 00:00:00 |                |
| mb_id      | varchar(20) | NO  | MUL |                    |                |
+-------------+-------------+------+-----+---------------------+----------------+
6 rows in set (0.00 sec)

인 경우

  $sql = " select bo_table, wr_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";

대신에

  $sql = " select bo_table, wr_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_id=wr_parent order by bn_id desc limit 0, $rows2 ";

를 사용하세요.
너무 너무 감사합니다. 막 이 함수 필요하던 차에 찾아보니 여기 있어서 너무 반갑네요. 덕분에 제가 삽질을 면하게 되었습니다.
업데이트까지 잊지않고 해주셔서 감사하네요, 위에 말씀하신대로 함수를 바꾸니 잘 실행되는군요.
전체 57 |RSS
그누4 팁자료실 내용 검색

회원로그인

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