여러 게시판 대상으로 공지글만 모으다......
여러 게시판 대상으로 공지글만 모으다 말았습니다.
$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개
지금 쓸껀 아니지만 써먹어봐야겠네요 나중에 홈피 리뉴얼할때 ㅎㅎ
추천합니당+_+
<?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;
}
?>
게시판 목록
그누4 팁자료실
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3309 | 3년 전 | 1806 | ||
| 3308 | 11년 전 | 2093 | ||
| 3307 |
uPAmJ903
|
6년 전 | 4753 | |
| 3306 |
바른사나이
|
6년 전 | 3274 | |
| 3305 | 6년 전 | 12312 | ||
| 3304 | 7년 전 | 3705 | ||
| 3303 | 7년 전 | 3745 | ||
| 3302 |
지리산초보
|
7년 전 | 13597 | |
| 3301 |
sozet
|
8년 전 | 4905 | |
| 3300 |
sozet
|
8년 전 | 5974 | |
| 3299 |
sozet
|
8년 전 | 10863 | |
| 3298 | 8년 전 | 4017 | ||
| 3297 |
또치하우스
|
8년 전 | 4444 | |
| 3296 | 8년 전 | 11972 | ||
| 3295 |
또치하우스
|
8년 전 | 14988 | |
| 3294 | 8년 전 | 6028 | ||
| 3293 | 8년 전 | 5593 | ||
| 3292 |
|
9년 전 | 5320 | |
| 3291 | 9년 전 | 13683 | ||
| 3290 | 9년 전 | 5055 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기