여러 게시판을 대상으로 최신글 뽑아 오기
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() 함수에 원하시는 만큼 쓰세요.
설치 방법은 위 게시물을 참고하세요.
댓 글 소스를 위 게시물에 있는 파일과 바꾸시거나 내용을 수정하시면 됩니다.
사용법은
<?php echo latest_group("simple", array( 'board02', 'board04', 'and_so_on'), 3, 27); ?>
게시판 아이디 갯수는 array() 함수에 원하시는 만큼 쓰세요.
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 19개
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;
}
?>
원하던 소스입니다.^^
right_menu.inc.php 인가요?
이거 쓰시면 될 듯합니다.
늘 행복하시길....
$list[$j][bo_name] = $board[bo_subject]; 이게 무슨뜻인지 모르겠어요
ㅠㅠ 아시는분없나요?
+-------------+-------------+------+-----+---------------------+----------------+
| 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 ";
를 사용하세요.
업데이트까지 잊지않고 해주셔서 감사하네요, 위에 말씀하신대로 함수를 바꾸니 잘 실행되는군요.