여러 게시판을 대상으로 최신글 뽑아 오기 정보
여러 게시판을 대상으로 최신글 뽑아 오기
본문
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() 함수에 원하시는 만큼 쓰세요.
추천
9
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;
}
?>
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 인가요?
right_menu.inc.php 인가요?
아하...right_menu.inc.php가 아니라 스킨안에 있는 리스트스킨php맞겠죠;?ㅎㅎ;..
에잇...잘 모르겠어요.ㅠ_ㅠ;

lib밑에 있는 latest.group.lib.php 쯤 될 겁니다.
오호 해결되었습니다^^ 감사해요. 잘나옵니다.

감사합니다 ^^ 혹시 글 앞에 게시판 제목도 같이 출력 안됄까요?

$list[$j][bo_name] = $board[bo_subject];
이거 쓰시면 될 듯합니다.
이거 쓰시면 될 듯합니다.
xml님 감사합니다.
늘 행복하시길....
늘 행복하시길....

옷!!! 감사합니다~~

좋은 정보 감사합니다!!
감사합니다.
최신글에 [게시판제목]게시글제목 이렇게 나오게하고싶은데
$list[$j][bo_name] = $board[bo_subject]; 이게 무슨뜻인지 모르겠어요
ㅠㅠ 아시는분없나요?
$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 ";
를 사용하세요.
+-------------+-------------+------+-----+---------------------+----------------+
| 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 ";
를 사용하세요.

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