그룹 최신글
참고 https://sir.kr/qa/405898
추가 사항
1. lib/common.lib.php
function sql_query()에서 union을 허용 필요합니다.
2. lastet skin에서 bo_table은 $list 안에 있는 것을 써야 합니다.
3. cache 기능이 없습니다.
4. 대용량 DB에는 적합하지 않습니다.
function glatest($skin_dir='', $gr_id, $rows=10, $subject_len=40, $cache_time=1, $options='') {
global $g5;
if (!$skin_dir) $skin_dir = 'basic';
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
if (G5_IS_MOBILE) {
$latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
if(!is_dir($latest_skin_path))
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
} else {
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
}
$skin_dir = $match[1];
} else {
if(G5_IS_MOBILE) {
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
} else {
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
}
}
$sqlg="select bo_table,bo_subject_len,bo_notice,bo_use_list_content,bo_use_sideview,bo_new,bo_hot,bo_use_list_file from {$g5['board_table']} where gr_id='$gr_id' ";
$reg = sql_query( $sqlg);
$board_set=array();
$sql=" select A.* from ( ";
if ( $row = sql_fetch_array( $reg)) {
$sql .=" ( select '{$row['bo_table']}' bo_table, g5_write_{$row['bo_table']}.* from g5_write_{$row['bo_table']} where wr_is_comment=0 order by wr_hit DESC limit 10 ) ";
$board_set[ $row['bo_table']]=$row;
while( $row = sql_fetch_array( $reg)) {
$sql .=" union ( select '{$row['bo_table']}' bo_table, g5_write_{$row['bo_table']}.* from g5_write_{$row['bo_table']} where wr_is_comment=0 order by wr_hit DESC limit 10 ) ";
$board_set[ $row['bo_table']]=$row;
}
$sql .=" ) A order by wr_hit limit 10 ";
}
$list = array();
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
try {
unset($row['wr_password']); //패스워드 저장 안함( 아예 삭제 )
} catch (Exception $e) {
}
$row['wr_email'] = ''; //이메일 저장 안함
if (strstr($row['wr_option'], 'secret')){ // 비밀글일 경우 내용, 링크, 파일 저장 안함
$row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';
$row['file'] = array('count'=>0);
}
$list[$i] = get_list( $row, $board_set['bo_table'], $latest_skin_url, $subject_len);
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
댓글 3개
<?php echo glatest('theme/basic', 'aa', 10, 40, 1,); ?>
입력해보니 오류떠요 ^^;;
<?php echo glatest('theme/basic', 'aa', 10, 40, 1,); ?>
이걸 그대로 쓰셨다면 제일 마지막에 콤마가 하나 더 들어간 게 문제 아닐까 싶습니다.
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4443 | ||
| 2694 | 2개월 전 | 206 | ||
| 2693 | 2개월 전 | 162 | ||
| 2692 | 2개월 전 | 170 | ||
| 2691 | 2개월 전 | 184 | ||
| 2690 | 2개월 전 | 336 | ||
| 2689 | 2개월 전 | 247 | ||
| 2688 |
|
2개월 전 | 450 | |
| 2687 | 3개월 전 | 302 | ||
| 2686 |
선택과집중
|
3개월 전 | 340 | |
| 2685 | 3개월 전 | 302 | ||
| 2684 | 3개월 전 | 361 | ||
| 2683 | 3개월 전 | 494 | ||
| 2682 | 3개월 전 | 285 | ||
| 2681 | 3개월 전 | 312 | ||
| 2680 |
선택과집중
|
3개월 전 | 284 | |
| 2679 | 3개월 전 | 341 | ||
| 2678 |
|
3개월 전 | 437 | |
| 2677 |
|
3개월 전 | 511 | |
| 2676 | 3개월 전 | 336 | ||
| 2675 | 3개월 전 | 314 | ||
| 2674 |
선택과집중
|
3개월 전 | 489 | |
| 2673 |
|
3개월 전 | 330 | |
| 2672 | 3개월 전 | 347 | ||
| 2671 | 3개월 전 | 296 | ||
| 2670 | 3개월 전 | 269 | ||
| 2669 | 3개월 전 | 383 | ||
| 2668 | 3개월 전 | 297 | ||
| 2667 |
선택과집중
|
3개월 전 | 496 | |
| 2666 |
선택과집중
|
4개월 전 | 481 | |
| 2665 |
선택과집중
|
4개월 전 | 419 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기